From 985da032f3d37518e7baf7944693dd730cfdf591 Mon Sep 17 00:00:00 2001 From: Chomtana Date: Thu, 11 Apr 2024 00:22:37 +0700 Subject: [PATCH] Temporary fix for cloudflare "The script will never generate a response" --- op-gateway/src/worker.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/op-gateway/src/worker.ts b/op-gateway/src/worker.ts index 5a0f468e..1ed60c33 100644 --- a/op-gateway/src/worker.ts +++ b/op-gateway/src/worker.ts @@ -9,11 +9,12 @@ interface Env { DELAY: number; TYPE: number; } -let app: Router; +// let server: Server; async function fetch(request: Request, env: Env) { // Loading libraries dynamically as a temp work around. // Otherwise, deployment thorws "Error: Script startup exceeded CPU time limit." error - if (!app) { + let server: Server; + // if (!server) { const ethers = await import('ethers'); const EVMGateway = (await import('@ensdomains/evm-gateway')).EVMGateway; const OPProofService = (await import('./OPProofService.js')).OPProofService; @@ -47,10 +48,10 @@ async function fetch(request: Request, env: Env) { const gateway = new EVMGateway(proofService); - const server = new Server(); + server = new Server(); gateway.add(server); - app = server.makeApp('/'); - } + // } + const app: Router = server.makeApp('/'); return app.handle(request); }