Skip to content

fix(twilio-run): fix global scope in forked process #270

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

Merged
merged 1 commit into from
May 20, 2021

Conversation

dkundel
Copy link
Contributor

@dkundel dkundel commented May 20, 2021

We were requiring the respective Function file before the global scope was created. If a user was
referencing a global object such as Runtime outside of the handler function it would throw an
UnhandledPromiseException because the Runtime wasn't constructed yet. This change only requires the
Function right before execution. This will also create more accurate timing results for cold starts.

During the fix I realized that the Function was also required twice, once by the Server and once by
the forked process. The server should only require the Function if it's not a forked process.

Contributing to Twilio

All third-party contributors acknowledge that any contributions they provide will be made under the same open-source license that the open-source project is provided under.

  • I acknowledge that all my contributions will be made under the project's license.

We were requiring the respective Function file before the global scope was created. If a user was
referencing a global object such as `Runtime` outside of the `handler` function it would throw an
UnhandledPromiseException because the Runtime wasn't constructe yet. This change only requires the
Function right before execution. This will also create more acurate timing results for cold starts.
During the fix I realized that the Function was also required twice, once by the Server and once by
the forked process. The server should only require the Function if it's not a forked process.
@dkundel dkundel merged commit d705f8e into main May 20, 2021
@dkundel dkundel deleted the dkundel/fix-forked-process branch May 20, 2021 21:59
dkundel added a commit that referenced this pull request May 20, 2021
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.

2 participants