Skip to content

Add option to disable async#246

Merged
patriksimek merged 3 commits into
patriksimek:masterfrom
XmiliaH:fix-180
Mar 20, 2020
Merged

Add option to disable async#246
patriksimek merged 3 commits into
patriksimek:masterfrom
XmiliaH:fix-180

Conversation

@XmiliaH
Copy link
Copy Markdown
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.
@XmiliaH XmiliaH requested a review from patriksimek September 18, 2019 22:12
via Object.getPrototypeOf((function*(){}).constructor)
@stale
Copy link
Copy Markdown

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
Copy Markdown
Owner

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

@XmiliaH XmiliaH deleted the fix-180 branch March 20, 2020 21:27
@gabegorelick
Copy link
Copy Markdown

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
Copy Markdown
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
Copy Markdown

@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