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

Added a 30 Minute timeout for infinite loops #12570

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

### Features

- `[jest-runtime]` Added `defaultTimeout` ([#12570](https://github.com/facebook/jest/pull/12570))
- `[babel-jest]` Export `createTransformer` function ([#12399](https://github.com/facebook/jest/pull/12399))
- `[expect]` Expose `AsymmetricMatchers`, `MatcherFunction` and `MatcherFunctionWithState` interfaces ([#12363](https://github.com/facebook/jest/pull/12363), [#12376](https://github.com/facebook/jest/pull/12376))
- `[jest-circus, jest-jasmine2]` Allowed classes and functions as `describe` and `it`/`test` names ([#12484](https://github.com/facebook/jest/pull/12484))
Expand Down
7 changes: 6 additions & 1 deletion packages/jest-runtime/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1449,8 +1449,13 @@ export default class Runtime {

const vmContext = this._environment.getVmContext();

const defaultTimeout = 30;

if (vmContext) {
runScript = script.runInContext(vmContext, {filename});
runScript = script.runInContext(vmContext, {
filename,
timeout: defaultTimeout * 60000,
});

Choose a reason for hiding this comment

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

I have tested that code with Node.js (16.x) and an infinite loop in my test -- it does not work.
I'm also confused: According to
https://nodejs.org/api/vm.html#scriptrunincontextcontextifiedobject-options
the options parameter only support displayErrors, timeout and breakOnSigint -- but no filename.

}

if (runScript !== null) {
Expand Down