()
| 33 | const tracer = trace.getTracer("executor-cloud-quickjs"); |
| 34 | |
| 35 | export const preloadQuickJs = (): Promise<void> => { |
| 36 | if (!preloaded) { |
| 37 | // oxlint-disable-next-line executor/no-promise-catch -- boundary: this module has no Effect context; reset the memoized promise on failure so a retried artifact render can trigger a fresh instantiation instead of caching a permanent rejection |
| 38 | preloaded = tracer |
| 39 | .startActiveSpan("quickjs.preload", async (span) => { |
| 40 | // oxlint-disable-next-line executor/no-try-catch-or-throw -- boundary: promise-native WASM instantiation; recording exception detail on the span before rethrowing |
| 41 | try { |
| 42 | const variant = newVariant(baseVariant, { wasmModule }); |
| 43 | const mod = await newQuickJSWASMModuleFromVariant(variant); |
| 44 | setQuickJSModule(mod); |
| 45 | } catch (err) { |
| 46 | // oxlint-disable-next-line executor/no-instanceof-error, executor/no-unknown-error-message -- boundary: normalizing an untyped instantiation failure only for the OTel span record; the original error is rethrown below unchanged |
| 47 | const cause = err instanceof Error ? err : String(err); |
| 48 | span.recordException(cause); |
| 49 | // oxlint-disable-next-line executor/no-unknown-error-message -- boundary: same normalization as the recordException line above |
| 50 | const message = typeof cause === "string" ? cause : cause.message; |
| 51 | span.setStatus({ code: SpanStatusCode.ERROR, message }); |
| 52 | // oxlint-disable-next-line executor/no-try-catch-or-throw -- boundary: rethrow after recording so the caller (and the memoization reset below) still observes the failure |
| 53 | throw err; |
| 54 | } finally { |
| 55 | span.end(); |
| 56 | } |
| 57 | }) |
| 58 | // oxlint-disable-next-line executor/no-promise-catch -- boundary: this module has no Effect context; reset the memoized promise on failure so a retried artifact render can trigger a fresh instantiation instead of caching a permanent rejection |
| 59 | .catch((err: unknown) => { |
| 60 | preloaded = null; |
| 61 | // oxlint-disable-next-line executor/no-try-catch-or-throw -- boundary: rethrow so the caller's awaited promise still rejects with the original error |
| 62 | throw err; |
| 63 | }); |
| 64 | } |
| 65 | return preloaded; |
| 66 | }; |
no test coverage detected