Skip to content

Comments

Error if there are pending items on the event queue#277

Merged
jeffcharles merged 7 commits intomainfrom
jc.error-if-pending-events
Mar 16, 2023
Merged

Error if there are pending items on the event queue#277
jeffcharles merged 7 commits intomainfrom
jc.error-if-pending-events

Conversation

@jeffcharles
Copy link
Collaborator

We've received feedback that the current behaviour of successfully exiting when items there are items enqueued on to the event loop that will never be executed is unexpected and they would prefer if the execution trapped with a helpful error message instead. This PR:

  • Adds an is_pending to Context to return whether there are pending jobs on the event queue
  • Changes the run bytecode logic to panic if there are pending jobs on the event queue with an exception if we're running the Web Platform Tests suite as the suite enqueues a promise as part of its setup
  • Disables a WPT suite that enqueues events

The check if we're running the WPT suite is done through a WASI environment variable. I opted to use this approach because:

  • I couldn't figure out a reasonable way to change how we run the WPT suite so that it doesn't enqueue the promise
  • we won't have to use a special build of Javy for the WPT suite
  • we don't have to touch the Javy CLI including adding support for additional arguments or env vars and plumbing it through to the core logic

I did take a look at the benchmarks to see if the WASI call to retrieve the env var value would have a performance impact and the results indicated no change in performance between main and this branch.

Copy link
Contributor

@jianghong jianghong left a comment

Choose a reason for hiding this comment

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

For when we release: Would you consider this a major change?

testFile: "upstream/encoding/replacement-encodings.any.js",
},
// { // FIXME requires the event loop
// testFile: "upstream/encoding/replacement-encodings.any.js",
Copy link
Contributor

Choose a reason for hiding this comment

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

It's unclear to me why this was needed to be commented out, could you clarify?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This actually doesn't need to be commented out any more since I disabled the error message with pending jobs. Technically the tests aren't completing properly but I can't figure out a way to have these tests error but have the suite setup to not cause a panic.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

So this does need to continue to be commented out or we get unhandled promise rejections due to Javy not implementing XMLHttpRequest when we run with the event loop enabled. I've updated the comment.

wpt/package.json Outdated
"bundle": "rollup -c rollup.config.js runner.js",
"javy": "../target/release/javy compile -o bundle.wasm bundle.js",
"wasmtime": "wasmtime bundle.wasm",
"wasmtime": "wasmtime --env JAVY_WPT=1 bundle.wasm",
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't know much about how the wpt stuff is built and ran yet but could we run it with the experimental_event_loop feature turned on? Would that help avoid needing to pass and checking this JAVY_WPT?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Tried to address that in #277 (comment). The short answer is yes, but I'd prefer to not do that because WPT would be testing something that doesn't behave like Javy would without the feature enabled.

@jeffcharles
Copy link
Collaborator Author

For when we release: Would you consider this a major change?

We can bump the minor version since we're 0.x. JS code that was working could stop working if it created pending jobs.

Copy link
Member

@saulecabrera saulecabrera left a comment

Choose a reason for hiding this comment

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

LGTM; thanks for all your patience iterating on this!

@jeffcharles jeffcharles merged commit 48821f8 into main Mar 16, 2023
@jeffcharles jeffcharles deleted the jc.error-if-pending-events branch March 16, 2023 17:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants