Skip to content

Fix: Always set [[ErrorToRethrow]] for import validation errors#11398

Merged
domenic merged 2 commits into
whatwg:mainfrom
nicolo-ribaudo:module-errors
Jun 26, 2025
Merged

Fix: Always set [[ErrorToRethrow]] for import validation errors#11398
domenic merged 2 commits into
whatwg:mainfrom
nicolo-ribaudo:module-errors

Conversation

@nicolo-ribaudo

@nicolo-ribaudo nicolo-ribaudo commented Jun 25, 2025

Copy link
Copy Markdown
Member

(deleting the template as this PR updates the spec text to match the intended behavior and the WPT tests)

Fixes #11338

The errors that do not set [[ErrorToRethrow]] are now the ones when:

  • the fetch fails
  • the fetch responds with a non-ok status
  • the mime type validation of the response fails

While the following errors do set it:

  • parsing error (already before this PR)
  • specifier resolution errors
  • import attributes validation errors

Which I believe matches the original behavior.

I think I will follow up with a small editorial PR to use the ThrowCompletion AO from ECMA-262 when creating throw completions to pass to FinishLoadingImportedModule, rather than manually creating them.


/webappapis.html ( diff )

@domenic domenic left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks!

For future reference, I think the PR template would still be valuable for cases like this, you'll just be able to check all the boxes easily. Especially verifying that this behavior is WPT-tested is nice. (But I guess the linked issue lets people do that without much work.)

This is in preparation for fixing whatwg#11338, which will expand its usage from pure parsing errors to also specifier resolution errors and import attribute validation errors.
Fixes whatwg#11338. This regressed in 430582c. Now the window error event, instead of the script element error event, will be fired for specifier resolution errors and import attribute validation errors, as it was prior to that commit.
@domenic
domenic merged commit f6fb04a into whatwg:main Jun 26, 2025
2 checks passed
@nicolo-ribaudo
nicolo-ribaudo deleted the module-errors branch June 26, 2025 07:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

fetch the descendants of and link a module script only handles [[ParseError]] case

2 participants