Attempt to fix tests.

This commit is contained in:
Sam Rose 2024-01-24 15:56:17 +00:00
parent f0cecb6e15
commit 1c3069178f
No known key found for this signature in database
1 changed files with 10 additions and 10 deletions

View File

@ -74,16 +74,6 @@ export function init() {
throw new Error(`No imports allowed. Required: ${specifier}`) throw new Error(`No imports allowed. Required: ${specifier}`)
}) })
const perRequestLimit = env.JS_PER_REQUEST_TIME_LIMIT_MS
if (perRequestLimit) {
const cpuMs = Number(jsIsolate.cpuTime) / 1e6
if (cpuMs > perRequestLimit) {
throw new Error(
`CPU time limit exceeded (${cpuMs}ms > ${perRequestLimit}ms)`
)
}
}
for (const [key, value] of Object.entries(ctx)) { for (const [key, value] of Object.entries(ctx)) {
if (key === "helpers") { if (key === "helpers") {
// Can't copy the native helpers into the isolate. We just ignore them as they are handled properly from the helpersSource // Can't copy the native helpers into the isolate. We just ignore them as they are handled properly from the helpersSource
@ -97,6 +87,16 @@ export function init() {
let { jsIsolate, jsContext, helpersModule } = bbCtx.isolateRefs! let { jsIsolate, jsContext, helpersModule } = bbCtx.isolateRefs!
const perRequestLimit = env.JS_PER_REQUEST_TIME_LIMIT_MS
if (perRequestLimit) {
const cpuMs = Number(jsIsolate.cpuTime) / 1e6
if (cpuMs > perRequestLimit) {
throw new Error(
`CPU time limit exceeded (${cpuMs}ms > ${perRequestLimit}ms)`
)
}
}
const script = jsIsolate.compileModuleSync( const script = jsIsolate.compileModuleSync(
`import helpers from "compiled_module";${js};cb(run());`, `import helpers from "compiled_module";${js};cb(run());`,
{} {}