GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — test: fix unreliable assumption in js-native-api/test_cannot_run_js by joyeecheung · Pull Request #51898 · nodejs/node

Conversation

@joyeecheung

@joyeecheung joyeecheung commented Feb 27, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Previously the test assumes that when the queued finalizer is run, it must be run at a point where env->can_call_into_js() is false (typically, during Environment shutdown), which is not certain. If GC kicks in early and the second pass finalizer is queued before the event loop runs the check callbacks, the finalizer would then be called in check callbacks (via native immediates), where the finalizer can still call into JS. Essentially, addons can't make assumptions about where the queued finalizer would be called. This patch updates the assertions in the test to account for that.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@nodejs-github-bot nodejs-github-bot added needs-ci PRs that need a full CI run. node-api Issues and PRs related to Node-API. test Issues and PRs related to Node.js core tests and test infrastructure. labels Feb 27, 2024
@joyeecheung joyeecheung mentioned this pull request Feb 27, 2024
deps: update V8 to 12.2 #51362
Closed
@joyeecheung
joyeecheung force-pushed the fix-test-cannot-run branch from 525308f to e3b6d32 Compare February 27, 2024 15:22
targos
targos approved these changes Feb 27, 2024
View reviewed changes

@targos targos left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM as a hotfix, but the test will basically become useless once V8 12.2 lands, as it will always return napi_ok then.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@joyeecheung
test: fix unreliable assumption in js-native-api/test_cannot_run_js
4165dca
Previously the test assumes that when the queued finalizer is run,
it must be run at a point where env->can_call_into_js() is false
(typically, during Environment shutdown), which is not certain.
If GC kicks in early and the second pass finalizer is queued before
the event loop runs the check callbacks, the finalizer would then
be called in check callbacks (via native immediates), where
the finalizer can still call into JS. Essentially, addons can't
make assumptions about where the queued finalizer would be called.
This patch updates the assertions in the test to account for that.
@joyeecheung
joyeecheung force-pushed the fix-test-cannot-run branch from e3b6d32 to 4165dca Compare February 27, 2024 15:36
@joyeecheung

joyeecheung commented Feb 27, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member Author

but the test will basically become useless once V8 12.2 lands, as it will always return napi_ok then.

That's not certain, it really depends on what the heap looks like when the addon is loaded. Any subtle change to the internals can delay the GC to happen after the check callbacks are called in the event loop (or not happen at all), and then it'll be napi_cannot_run_js again (and become a flaky nightmare). The fix just makes sure that it works for all cases (no matter GC kicks in before or after check callbacks, or if it doesn't happen at all)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@richardlau

richardlau commented Feb 27, 2024

Copy link
Copy Markdown
Member

If this fixes the test, perhaps remove the flaky designation in

node/test/root.status

Line 2 in f28ccd3

js-native-api/test_cannot_run_js/test: PASS,FLAKY
?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@joyeecheung
fixup! test: fix unreliable assumption in js-native-api/test_cannot_r…
e69bbce
…un_js
@joyeecheung

joyeecheung commented Feb 27, 2024

Copy link
Copy Markdown
Member Author

If this fixes the test, perhaps remove the flaky designation in

Updated the status file - was the designation even working in the first place? It still got caught in the CI it seems, and locally the test runner still reports it. (I think it should've been marked as PASS,CRASH instead?)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@joyeecheung joyeecheung added the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Feb 27, 2024
@richardlau

richardlau commented Feb 27, 2024

Copy link
Copy Markdown
Member

If this fixes the test, perhaps remove the flaky designation in

Updated the status file - was the designation even working in the first place? It still got caught in the CI it seems, and locally the test runner still reports it. (I think it should've been marked as PASS,CRASH instead?)

Yes, it was working -- e.g. https://ci.nodejs.org/job/node-test-commit-ibmi/nodes=ibmi73-ppc64/1466/ (from #48180 (comment)) is yellow due to this test crashing and not red.

joyeecheung reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

richardlau
richardlau approved these changes Feb 27, 2024
View reviewed changes
@richardlau richardlau linked an issue Feb 27, 2024 that may be closed by this pull request
Flaky js-native-api/test_cannot_run_js/test #48180
Closed
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Feb 27, 2024
@nodejs-github-bot

nodejs-github-bot commented Feb 27, 2024

Copy link
Copy Markdown
Collaborator

CI: https://ci.nodejs.org/job/node-test-pull-request/57467/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@marco-ippolito marco-ippolito mentioned this pull request Feb 27, 2024
lib: only build the ESM facade for builtins when they are needed #51669
Closed
@marco-ippolito marco-ippolito added the v21.x label Feb 27, 2024
marco-ippolito
marco-ippolito approved these changes Feb 27, 2024
View reviewed changes
@richardlau

richardlau commented Feb 28, 2024

Copy link
Copy Markdown
Member

It looks like the addon is failing to compile on Windows:
e.g. https://ci.nodejs.org/job/node-test-binary-windows-native-suites/21625/nodes=win10-vs2019-COMPILED_BY-vs2022/console

17:10:21 Failed to build addon in c:\workspace\node-test-binary-windows-native-suites\node\test\js-native-api\test_cannot_run_js:
17:10:21 Building the projects in this solution one at a time. To enable parallel build, please add the "-m" switch.

17:10:21   test_cannot_run_js.c

17:10:21 c:\workspace\node-test-binary-windows-native-suites\node\test\js-native-api\test_cannot_run_js\test_cannot_run_js.c(28,1): error C2121: '#': invalid character: possibly the result of a macro expansion [c:\workspace\node-test-binary-windows-native-suites\node\test\js-native-api\test_cannot_run_js\build\test_cannot_run_js.vcxproj]

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

legendecas
legendecas approved these changes Feb 29, 2024
View reviewed changes
@StefanStojanovic

StefanStojanovic commented Feb 29, 2024

Copy link
Copy Markdown
Contributor

It looks like the addon is failing to compile on Windows

I tried this locally and can confirm the behavior. What fixed the compilation for me was this. @joyeecheung if you think it's good, feel free to apply it.

diff --git a/test/js-native-api/test_cannot_run_js/test_cannot_run_js.c b/test/js-native-api/test_cannot_run_js/test_cannot_run_js.c
index 925a7117d06..19cc7ae9058 100644
--- a/test/js-native-api/test_cannot_run_js/test_cannot_run_js.c
+++ b/test/js-native-api/test_cannot_run_js/test_cannot_run_js.c
@@ -21,12 +21,13 @@ static void Finalize(napi_env env, void* data, void* hint) {
   // or during environment shutdown (where napi_cannot_run_js or
   // napi_pending_exception is returned). This is not deterministic from
   // the point of view of the addon.
-  NODE_API_NOGC_ASSERT_RETURN_VOID(
 #ifdef NAPI_EXPERIMENTAL
+  NODE_API_NOGC_ASSERT_RETURN_VOID(
       result == napi_cannot_run_js || result == napi_ok,
       "getting named property from global in finalizer should succeed "
       "or return napi_cannot_run_js");
 #else
+  NODE_API_NOGC_ASSERT_RETURN_VOID(
       result == napi_pending_exception || result == napi_ok,
       "getting named property from global in finalizer should succeed "
       "or return napi_pending_exception");

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@joyeecheung
fixup! fixup! test: fix unreliable assumption in js-native-api/test_c…
d78f663
…annot_run_js
@joyeecheung joyeecheung added the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Feb 29, 2024
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Feb 29, 2024
@nodejs-github-bot

nodejs-github-bot commented Feb 29, 2024

Copy link
Copy Markdown
Collaborator

CI: https://ci.nodejs.org/job/node-test-pull-request/57508/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@marco-ippolito marco-ippolito mentioned this pull request Feb 29, 2024
Major bug was fixed in [email protected] concerning apps started with npm start #51923
Closed
@nodejs-github-bot

nodejs-github-bot commented Feb 29, 2024

Copy link
Copy Markdown
Collaborator

CI: https://ci.nodejs.org/job/node-test-pull-request/57511/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@nodejs-github-bot

nodejs-github-bot commented Mar 1, 2024

Copy link
Copy Markdown
Collaborator

CI: https://ci.nodejs.org/job/node-test-pull-request/57516/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

richardlau
richardlau approved these changes Mar 1, 2024
View reviewed changes
@richardlau richardlau added commit-queue PRs queued for automated landing through the Commit Queue. commit-queue-squash PRs the Commit Queue should land as one squashed commit. labels Mar 1, 2024
@nodejs-github-bot nodejs-github-bot removed the commit-queue PRs queued for automated landing through the Commit Queue. label Mar 1, 2024
@nodejs-github-bot
nodejs-github-bot merged commit 30c9181 into nodejs:main Mar 1, 2024
@nodejs-github-bot

nodejs-github-bot commented Mar 1, 2024

Copy link
Copy Markdown
Collaborator

Landed in 30c9181

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

marco-ippolito pushed a commit that referenced this pull request Mar 1, 2024
@joyeecheung @marco-ippolito
test: fix unreliable assumption in js-native-api/test_cannot_run_js
17ab5ae
Previously the test assumes that when the queued finalizer is run,
it must be run at a point where env->can_call_into_js() is false
(typically, during Environment shutdown), which is not certain.
If GC kicks in early and the second pass finalizer is queued before
the event loop runs the check callbacks, the finalizer would then
be called in check callbacks (via native immediates), where
the finalizer can still call into JS. Essentially, addons can't
make assumptions about where the queued finalizer would be called.
This patch updates the assertions in the test to account for that.

PR-URL: #51898
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: Richard Lau <[email protected]>
Reviewed-By: Marco Ippolito <[email protected]>
Reviewed-By: Chengzhong Wu <[email protected]>
@marco-ippolito marco-ippolito mentioned this pull request Mar 1, 2024
v21.7.0 proposal #51932
Merged
@toyobayashi toyobayashi mentioned this pull request Mar 9, 2024
test: fix unreliable assumption in js-native-api/test_cannot_run_js toyobayashi/emnapi#111
Merged
richardlau pushed a commit that referenced this pull request Mar 25, 2024
@joyeecheung @richardlau
test: fix unreliable assumption in js-native-api/test_cannot_run_js
136b6a9
Previously the test assumes that when the queued finalizer is run,
it must be run at a point where env->can_call_into_js() is false
(typically, during Environment shutdown), which is not certain.
If GC kicks in early and the second pass finalizer is queued before
the event loop runs the check callbacks, the finalizer would then
be called in check callbacks (via native immediates), where
the finalizer can still call into JS. Essentially, addons can't
make assumptions about where the queued finalizer would be called.
This patch updates the assertions in the test to account for that.

PR-URL: #51898
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: Richard Lau <[email protected]>
Reviewed-By: Marco Ippolito <[email protected]>
Reviewed-By: Chengzhong Wu <[email protected]>
@richardlau richardlau mentioned this pull request Mar 25, 2024
v20.12.0 proposal #52212
Merged
@richardlau richardlau mentioned this pull request Sep 26, 2024
[v18.x backport] test: update TLS tests for OpenSSL 3.2 #55101
Merged
richardlau pushed a commit that referenced this pull request Sep 26, 2024
@joyeecheung @richardlau
test: fix unreliable assumption in js-native-api/test_cannot_run_js
627d399
Previously the test assumes that when the queued finalizer is run,
it must be run at a point where env->can_call_into_js() is false
(typically, during Environment shutdown), which is not certain.
If GC kicks in early and the second pass finalizer is queued before
the event loop runs the check callbacks, the finalizer would then
be called in check callbacks (via native immediates), where
the finalizer can still call into JS. Essentially, addons can't
make assumptions about where the queued finalizer would be called.
This patch updates the assertions in the test to account for that.

PR-URL: #51898
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: Richard Lau <[email protected]>
Reviewed-By: Marco Ippolito <[email protected]>
Reviewed-By: Chengzhong Wu <[email protected]>
@aduh95 aduh95 mentioned this pull request Nov 7, 2024
2024-11-12, Version 18.20.5 'Hydrogen' (LTS) #55768
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@richardlau richardlau richardlau approved these changes
@legendecas legendecas legendecas approved these changes
@marco-ippolito marco-ippolito marco-ippolito approved these changes
+1 more reviewer
@targos targos targos approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

commit-queue-squash PRs the Commit Queue should land as one squashed commit. needs-ci PRs that need a full CI run. node-api Issues and PRs related to Node-API. test Issues and PRs related to Node.js core tests and test infrastructure.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Flaky js-native-api/test_cannot_run_js/test

Uh oh!

There was an error while loading. Please reload this page.

7 participants

@joyeecheung @richardlau @nodejs-github-bot @StefanStojanovic @targos @legendecas @marco-ippolito
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.