Skip to content

fix: allow sync return from wrapScriptExecution and wrapNetworkRequest hooks #6795

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

mrazauskas
Copy link

@mrazauskas mrazauskas commented May 13, 2025

What's the problem this PR addresses?

Currently the typings of wrapScriptExecution and wrapNetworkRequest hooks only allow to return a Promise. There is no harm to allow a sync return, because the return will be anyways awaited at the runtime. A sync function can be awaited and it works as expected.

How did you fix it?

Updated the typings to allow sync returns.

I marked this change as a patch, because this is only an issue with typings. Might be I missed something, but it looks like all works fine at the runtime.

Checklist

  • I have set the packages that need to be released for my changes to be effective.
  • I will check that all automated PR checks pass before the PR gets reviewed.

@mrazauskas
Copy link
Author

Sidenotes:

  • bumped into this problem while putting together a plugin that hides the change.log file (another workaround for [Feature] Do not always include the changelog.* files in a package #6793)
  • strangely I can’t find a type which ensures that the exported plugin object has name and factory(). The Hooks type is very useful. The Plugin type is the return type of the factory(). But how should I type the whole exported thing? Hm.. What do I miss?

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.

1 participant