]> zoso.dev Git - nano-pow.git/commitdiff
Return if server requests have already been intercepted by puppeteer. Properly call...
authorChris Duncan <chris@zoso.dev>
Tue, 22 Apr 2025 13:22:18 +0000 (06:22 -0700)
committerChris Duncan <chris@zoso.dev>
Tue, 22 Apr 2025 13:22:18 +0000 (06:22 -0700)
src/bin/server.ts

index b4f2a8d686b54bf6f00e4180c751ea32cba84ab0..07cae54978bfd9524aedeb9859b9d32b500abf0a 100755 (executable)
@@ -265,12 +265,18 @@ const body = `
 
 await page.setRequestInterception(true)
 page.on('request', async (req): Promise<void> => {
+       if (req.isInterceptResolutionHandled()) return
        if (req.url() === 'https://nanopow.invalid/') {
                req.respond({ status: 200, contentType: 'text/html', body })
+       } else {
+               req.continue()
        }
 })
 page.on('console', msg => log(msg.text()))
 await page.goto('https://nanopow.invalid/')
+await page.waitForFunction(async (): Promise<boolean> => {
+       return window.NanoPow != null
+})
 
 log('Puppeteer initialized')