File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11name : Debug action
22
3- description : Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)
3+ description : Run the build with debugging enabled
44
55runs :
66 using : composite
77 steps :
8- - name : Debug
9- uses : mxschmitt/action-tmate@c0afd6f790e3a5564914980036ebf83216678101 # v3.23
8+ - name : Setup upterm session
9+ uses : owenthereal/action-upterm@v1
10+ with :
11+ limit-access-to-actor : true
Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ permissions:
99
1010jobs :
1111 debug :
12- name : Debug with tmate
12+ name : Debug with upterm
1313 runs-on : ubuntu-latest
1414
1515 steps :
1919 target : ' debug'
2020 needs-emscripten : ' true'
2121 needs-wasi-sdk : ' true'
22- - name : NPM Build
23- run : npm run build --workspaces --if-present
24- - name : Setup tmate session
22+ - name : Setup debug session
2523 uses : ./.github/actions/debugger
2624 if : ${{ github.event_name == 'workflow_dispatch' }}
Original file line number Diff line number Diff line change @@ -34,15 +34,20 @@ class TestWorker : public AsyncProgressWorker<ProgressData> {
3434 SetError (" test error" );
3535 }
3636 ProgressData data{0 };
37- std::unique_lock<std::mutex> lock (_cvm);
37+
3838 for (int32_t idx = 0 ; idx < _times; idx++) {
3939 data.progress = idx;
4040 progress.Send (&data, 1 );
41- _cv.wait (lock);
41+
42+ {
43+ std::unique_lock<std::mutex> lk (_cvm);
44+ _cv.wait (lk, [this ] { return dataSent; });
45+ dataSent = false ;
46+ }
4247 }
4348 }
4449
45- void OnProgress (const ProgressData* data, size_t /* count */ ) override {
50+ void OnProgress (const ProgressData* data, size_t count) override {
4651 Napi::Env env = Env ();
4752 if (!_progress.IsEmpty ()) {
4853 Number progress = Number::New (env, data->progress );
@@ -52,7 +57,12 @@ class TestWorker : public AsyncProgressWorker<ProgressData> {
5257 _progress.MakeCallback (Receiver ().Value (), {progress});
5358#endif
5459 }
55- _cv.notify_one ();
60+
61+ {
62+ std::lock_guard<std::mutex> lk (_cvm);
63+ dataSent = true ;
64+ _cv.notify_one ();
65+ }
5666 }
5767
5868 private:
@@ -63,6 +73,8 @@ class TestWorker : public AsyncProgressWorker<ProgressData> {
6373 : AsyncProgressWorker(cb, resource_name, resource) {
6474 _progress.Reset (progress, 1 );
6575 }
76+
77+ bool dataSent = false ;
6678 std::condition_variable _cv;
6779 std::mutex _cvm;
6880 int32_t _times;
Original file line number Diff line number Diff line change @@ -13,7 +13,6 @@ let ignore = [
1313 'rust/**/*' ,
1414 'tsfn2/tsfn2_st.test.js' ,
1515 'async/async_st.test.js' ,
16- 'node-addon-api/async_progress_worker.test.js' , // flaky test, needs investigation
1716]
1817
1918const pthread = [
Original file line number Diff line number Diff line change @@ -42,10 +42,11 @@ function loadPath (request, options) {
4242 }
4343
4444 if ( process . env . EMNAPI_TEST_WASI ) {
45- const { WASI } = require ( './ wasi' )
45+ const { WASI } = require ( 'node: wasi' )
4646 const { createNapiModule, loadNapiModule } = require ( '@emnapi/core' )
4747 const v8 = require ( '@emnapi/core/plugins/v8' ) . default
4848 const wasi = new WASI ( {
49+ version : 'preview1' ,
4950 fs
5051 } )
5152 const napiModule = createNapiModule ( {
You can’t perform that action at this time.
0 commit comments