Add an extra JS execution time limit check to prevent creating unnecesary VM context.
This commit is contained in:
parent
eabe74a2c1
commit
68468fadb3
|
@ -50,7 +50,7 @@ export class ExecutionTimeTracker {
|
|||
return this.totalTimeMs
|
||||
}
|
||||
|
||||
private checkLimit() {
|
||||
checkLimit() {
|
||||
if (this.totalTimeMs > this.limitMs) {
|
||||
throw new ExecutionTimeoutError(
|
||||
`Execution time limit of ${this.limitMs}ms exceeded: ${this.totalTimeMs}ms`
|
||||
|
|
|
@ -18,13 +18,16 @@ export function init() {
|
|||
bbCtx.jsExecutionTracker =
|
||||
timers.ExecutionTimeTracker.withLimit(perRequestLimit)
|
||||
}
|
||||
track = bbCtx.jsExecutionTracker.track.bind(bbCtx.jsExecutionTracker)
|
||||
span?.addTags({
|
||||
js: {
|
||||
limitMS: bbCtx.jsExecutionTracker.limitMs,
|
||||
elapsedMS: bbCtx.jsExecutionTracker.elapsedMS,
|
||||
},
|
||||
})
|
||||
// We call checkLimit() here to prevent paying the cost of creating
|
||||
// a new VM context below when we don't need to.
|
||||
bbCtx.jsExecutionTracker.checkLimit()
|
||||
track = bbCtx.jsExecutionTracker.track.bind(bbCtx.jsExecutionTracker)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue