Skip to content

Commit

Permalink
Temporary fix for cloudflare "The script will never generate a response"
Browse files Browse the repository at this point in the history
  • Loading branch information
Chomtana committed Apr 10, 2024
1 parent d381541 commit 985da03
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions op-gateway/src/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}

Expand Down

0 comments on commit 985da03

Please sign in to comment.