Uh oh!
There was an error while loading. Please reload this page.
tsfn: implement TypedThreadSafeFunction - #742
Conversation
KevinEady
commented
Jun 8, 2020
Hey @gabrielschulhof , @mhdawson ... Soooo I am a little stuck now. I have no idea why this is happening, but it seems that the I did as you suggested, and migrated the old "multi-threaded" TSFN test to this new TSFNEx methodology. The changes to do so seem minimal, so I'm not sure why this is erroring. I've added this This is what I've got in my debugger: and here's the stack... Hopefully we can discuss in today's call. |
Hi @gabrielschulhof , I took into a look into what you suggested, that maybe all threads have called I pinpointed the failure to this specific portion: // Start the thread in blocking mode, and assert that it could not finish.// Quit early by aborting..then(()=>testWithJSMarshaller({threadStarter: 'startThread',quitAfter: 1,maxQueueSize: binding.threadsafe_function_ex_threadsafe.MAX_QUEUE_SIZE,abort: true})).then((result)=>assert.strictEqual(result.indexOf(0),-1))... and when my So I think you are completely right: this test has the TSFN abort, so I suppose there are still items on the queue when an abort happens. So, am I correct that:
EDIT: I ask for clarification, because I want to put this in the documentation. I don't think it's inherently clear that your TSFN's "environment" is cleaned up on the last Do you know of any place where we have documentation about the "CallJS can be ran with empty napi env/function after the TSFN has been finalized, for you to process the remaining items on the queue" or whatever? |
It should actually check for empty jsCallback
gabrielschulhof
commented
Nov 19, 2020
From discussion in the meeting we came up with another suggestion which was |
KevinEady
commented
Nov 20, 2020
When #832 lands, I will rebase, rename, and push. |
mhdawson
commented
Nov 23, 2020
@KevinEady, landed #832 |
mhdawson
commented
Nov 23, 2020
@KevinEady we suggested |
be32dc8 to
559ad8cCompareKevinEady
commented
Nov 24, 2020
Hi @mhdawson , I have rebased + renamed to @gabrielschulhof / @mhdawson, can you run the CI? |
legendecas
commented
Nov 25, 2020
@KevinEady I'm not sure what's going on with TravisCI. We do have I checked the travis permission and found out that Node.js github org doesn't grant any public write access to travis. Not sure if it is a recent change. |
mhdawson
commented
Nov 27, 2020
12.x - https://ci.nodejs.org/view/x%20-%20Abi%20stable%20module%20API/job/node-test-node-addon-api-new/3157/ |
mhdawson
commented
Nov 30, 2020
12.x had a failure so re-run: https://ci.nodejs.org/view/x%20-%20Abi%20stable%20module%20API/job/node-test-node-addon-api-new/3174/ |
mhdawson
commented
Nov 30, 2020
This was the failure on 12.x on Mac 15 Running test'threadsafe_function/threadsafe_function_sum'
Build timed out (after 60 minutes). Marking the build as failed. |
KevinEady
commented
Nov 30, 2020
KevinEady
commented
Nov 30, 2020
Looks like https://ci.nodejs.org/view/x%20-%20Abi%20stable%20module%20API/job/node-test-node-addon-api-new/3174/ passed... do you think there is some issue with the original tsfn test? |
mhdawson
commented
Nov 30, 2020
Seems like the re-run I launched was on 16.x. Another one on 12.x this time: https://ci.nodejs.org/view/x%20-%20Abi%20stable%20module%20API/job/node-test-node-addon-api-new/3175/ @KevinEady my first guess is an existing problem with the test unless somehow the PR refactored code which the base ThreadSafeFunction uses? |
mhdawson
commented
Nov 30, 2020
Looks like this simply adds to napi-inl.h so most likely an existing flaky issue with the test. As long as the new 12.x run I launched passes I think we can land this PR. @KevinEady if you are ok to land then I think we should be good to go. |
mhdawson
commented
Dec 1, 2020
@legendecas are you ok with this landing now? Just want to make sure as it shows requested changes, but I think that was just to close on the name change. |
KevinEady
commented
Dec 1, 2020
@mhdawson I have no problems with that. |
gabrielschulhof
commented
Dec 4, 2020
@legendecas I think you can remove the -1, because the class was renamed. |
legendecas
left a comment
There was a problem hiding this comment.
Sorry for the delay. This is a great work! LGTM
gabrielschulhof
commented
Dec 7, 2020
CI on resulting master was green: |


Implements a templated
TypedThreadSafeFunction<ContextType, DataType, Callback>class. The class also adds static, compile-time support for the optionalFunctionargument on N-API 5+ usingstd::nullptr_t(as well as completely missingFunctionargument) on N-API 5+.TODO:
ThreadSafeFunctionclass can utilize this one, as done in previous POC tsfn: implement ThreadSafeFunctionEx for GCC 5+ #687 (comment)Fixes: