Repository navigation
Fixes in various places in existing code - #41
Merged
Merged
Conversation
Needed to pull in a newer `wasi-libc`, which fixes `__wasilibc_reset_preopens` to close open FDs in addition to resetting the preopens. Without calling that function right before wizening, all FDs opened during init are retained, including `stdout` and `stderr`. That means printing anything at wizening time causes a trap when printing post resumption. This needed light changes to `crown` as well, but nothing major.
The module load hook compiles a request with `with { type: "json" }` as a
JSON module, cached independently of a JavaScript module of the same file, and
refuses every other module type with a message naming the specifier.
For a dynamic `import()`, the hook loads the module's own imports before handing
the module over, and the engine links and evaluates it in a promise job after
`import()` has returned. Before this, every dynamic import failed with "module
record has unexpected status: New".
…first During `pre_initialize`, the runtime enables recording stacks for the creation of tasks, timers, interest handles and async-promise futures using `js::stack::current_origin`. If any of them are still active at snapshot time, `EventLoop::ensure_idle_for_snapshot` prints errors for them, including the recorded stacks. `mark_resumed_from_snapshot` becomes `prepare_for_snapshot`, which also flushes stdio and calls `__wasilibc_reset_preopens` to close any open FDs, including those for `stdout` and `stderr`.
Running a module as a command handed its evaluation promise to the event loop and dropped it, so a top level that rejected after awaiting a timer, or awaited a promise nothing could settle, exited with status 0 and no message. `ScriptEvaluation::settled`, called by `core_runtime::run`, the wasm `libstarling::run` and Wizer pre-initialization, checks both once the loop has run out of work.
`console.log`, `info` and `debug` print the bare message on stdout, and `warn` and `error` print it on stderr, prefixed with the level. Every level used to go to stdout behind a prefix. `js::jobs` tracks promises that are rejected while no handler is attached, and `run_microtasks` reports each one still unhandled after the drain on stderr, as `Uncaught (in promise)` with the reason's message, location and stack. A module's evaluation promise is marked handled when evaluation returns it, since the caller reports its rejection itself. Additionally, report more details, including the stack, on where a top-level error was thrown.
`heck` and `smallvec` are declared once in the workspace manifest, and `starling-macro` and `web-streams` refer to those declarations instead of naming versions of their own.
`platform::http::read_incoming_request` only calls sync host functions, so can be sync itself as well.
The entry module needs to be registered in the module registry same as any other module. Otherwise, importing it in other modules creates a second instance. This is also meaningfully simplifying module registration.
`core_runtime::module::register_source_module` was used by SpiderMonkey 147's module resolution hooks, but isn't used at all anymore.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR introduces yet another round of fixes in existing code. This time, most of this is centered around loading and evaluation of source code/modules during initialization, as well as error handling.