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

Add option to disable async #246

Merged
merged 3 commits into from
Mar 20, 2020
Merged

Conversation

XmiliaH
Copy link
Collaborator

@XmiliaH XmiliaH commented Sep 18, 2019

This is done by checking if the source contains the word 'async'.
This catches await, since it can only be used in async functions.
It wraps eval and function ctors and injects the async check there too.
This has some side effects like no direct eval support.
The option is currently opt in.
This should fix #180.

This is done by checking if the source contains the word 'async'.
This catches await, since it can only be used in async functions.
It wraps eval and function ctors and injects the async check there too.
This has some side effects like no direct eval support.
The option is currently opt in.
via Object.getPrototypeOf((function*(){}).constructor)
@stale
Copy link

stale bot commented Dec 23, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Dec 23, 2019
@XmiliaH XmiliaH removed the stale label Dec 23, 2019
@patriksimek patriksimek merged commit ed7215f into patriksimek:master Mar 20, 2020
@patriksimek
Copy link
Owner

Thanks for your contribution! I'm sorry I was not able to merge that sooner.

@gabegorelick
Copy link

Is there a reason this was implemented with such a broad regex? It ends up blocking things like declaring a variable named async (#249).

Is there a way to only stop async functions? Or perhaps stopping await instead?

@XmiliaH
Copy link
Collaborator Author

XmiliaH commented Apr 6, 2020

Stopping await is not needed, since creating an async function and calling it will result in it being run later on, so we need to filter out async functions. The regex is so broad since a better one whould be verry complicated and errorprone, for example whitespaces can contain comments,

@jedwards1211
Copy link

@XmiliaH Why not parse the code into an AST and see if any function nodes are marked async?

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.

Not immune to while(1){}
4 participants