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

Undefine globals, not just shadow #43

Merged
merged 3 commits into from Jun 21, 2016
Merged

Undefine globals, not just shadow #43

merged 3 commits into from Jun 21, 2016

Conversation

josh
Copy link
Contributor

@josh josh commented Jun 5, 2016

Shadowed globals maybe also accessed via this.console. This normalizes these globals across all runners. See FAQ (https://github.com/rails/execjs#faq) for why these globals should not be exposed during evaluation.

Related #42.

Node specific global should be normalized across environments
@rails-bot
Copy link

r? @schneems

(@rails-bot has picked a reviewer for you, use r? to override)

@josh josh changed the title Undefine global process Undefine globals, not just shadow Jun 5, 2016
delete this.clearTimeout;
delete this.clearInterval;
delete this.setImmediate;
delete this.clearImmediate;
result = program();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Someday we could move Nodes execution over to vm.Script. We'd have full control over what globals were exposed to the v8 context. vm.Script also has nice support for timeouts.

Copy link
Member

Choose a reason for hiding this comment

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

What is blocking us to change this right now? The version of node that support vm.Script?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The version of node that support vm.Script?

It is well supported, but that change would be a substantial refactoring.

Copy link
Member

Choose a reason for hiding this comment

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

Got it. Thanks.

@josh
Copy link
Contributor Author

josh commented Jun 21, 2016

cc @arthurnn

@rafaelfranca rafaelfranca merged commit e57706f into rails:master Jun 21, 2016
@josh
Copy link
Contributor Author

josh commented Jun 21, 2016

🎉 thanks @rafaelfranca!

@josh josh deleted the undef-process branch June 21, 2016 16:23
@rafaelfranca
Copy link
Member

Thank you. I'll release a new version later today.

@eventualbuddha
Copy link

@rafaelfranca. Any chance of that new version this week?

@rafaelfranca
Copy link
Member

Yes. I can do in a few minutes.

tf added a commit to tf/video.js that referenced this pull request May 25, 2021
In some server side rendering environments (e.g., `execjs` since
version 2.8.0 [1]) `setTimeout` is not available. Since
`autoSetupTimeout` runs when Video.js is imported and tries to
schedule `autoSetup`, this can lead to errors of the form in server
side rendering:

    TypeError: scheduler is not a function

`autoSetup` already bailed if run outside of a browser environment or
if it has been globally disabled. To prevent calling `setTimeout`, we
move the `Dom.isReal` check into `autoSetupTimeout`. Checking
`options.autoSetup` has to remain in `autoSetup` to preserve backwards
compatiblity with apps that set the option after Video.js has loaded
but before the next tick.

[1] rails/execjs#43
tf added a commit to tf/video.js that referenced this pull request May 25, 2021
In some server side rendering environments (e.g., `execjs` since
version 2.8.0 [1]) `setTimeout` is not available. Since
`autoSetupTimeout` runs when Video.js is imported and tries to
schedule `autoSetup`, this can lead to errors of the following form in
server side rendering:

    TypeError: scheduler is not a function

`autoSetup` already bailed out if run outside of a browser environment
or if globally disabled. To prevent calling `setTimeout`, we already
perform the `Dom.isReal` check in `autoSetupTimeout`. Checking
`options.autoSetup` has to remain in `autoSetup` to preserve backwards
compatiblity with apps that set the option after Video.js has loaded
but before the next tick.

[1] rails/execjs#43
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.

None yet

5 participants