Skip to content
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

Use await import instead of require for functions modules that contain top-level awaits #1651

Merged
merged 7 commits into from
Dec 19, 2024

Conversation

Berlioz
Copy link
Contributor

@Berlioz Berlioz commented Dec 13, 2024

firebase/firebase-tools#8054 surfaced an issue in which functions containing top-level awaits threw ERR_REQUIRE_ASYNC_MODULE errors during functions discovery, due to changes in Node 22.12 (https://github.com/nodejs/node/blob/main/doc/changelogs/CHANGELOG_V22.md#requireesm-is-now-enabled-by-default).

Previously, ES modules containing top-level awaits would be imported via awaiting an import() instead of require() in a catch block after the require failed. Extending the catch conditions to cover this new error should deal with current regressions, while we consider if we need to do any other work.

Fixes firebase/firebase-tools#8054

@taeold
Copy link
Contributor

taeold commented Dec 13, 2024

Can we add a test case in

https://github.com/firebase/firebase-functions/tree/master/scripts/bin-test/sources?

We will also want to expand our text matrics to test against node 22 so we can actually make sure this issue is fixed:

Copy link
Contributor

@taeold taeold left a comment

Choose a reason for hiding this comment

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

Add Changelog?

inlined and others added 4 commits December 18, 2024 16:19
…led (#1650)

* Add support for an authPolicy that returns Permission Denied when failed

* Formatter

* Changelog

* remove ignorant comment
* Update streaming callable API

* Fix linter error

* Stream type defaults to unknown

* Changelog

* Format fix
@Berlioz Berlioz added this pull request to the merge queue Dec 19, 2024
Merged via the queue into master with commit db8e3db Dec 19, 2024
17 checks passed
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.

ERR_REQUIRE_ASYNC_MODULE when deploying with Node.js v22.12.0
3 participants