Skip to content

Commit 9cfc1cd

Browse files
committed
fix(server): Update timers for limited execution environments
In limited execution environments the setTimeout/clearTimeout functions need to be delegated to, rather than stored as references, otherwise an Illegal Invocation error is thrown by the runtime. Closes #1519
1 parent f60e194 commit 9cfc1cd

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

lib/server.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ var di = require('di')
33
var util = require('util')
44
var Promise = require('bluebird')
55

6+
var root = global || window || this
7+
68
var cfg = require('./config')
79
var logger = require('./logger')
810
var constant = require('./constants')
@@ -72,7 +74,10 @@ var Server = function (cliOptions, done) {
7274
reporter: ['factory', reporter.createReporters],
7375
capturedBrowsers: ['type', BrowserCollection],
7476
args: ['value', {}],
75-
timer: ['value', {setTimeout: setTimeout, clearTimeout: clearTimeout}]
77+
timer: ['value', {
78+
setTimeout: function () { return setTimeout.apply(root, arguments)},
79+
clearTimeout: function (timeoutId) { clearTimeout(timeoutId)}
80+
}]
7681
}]
7782

7883
// Load the plugins

0 commit comments

Comments
 (0)