rtsao / css-to-js-sourcemap

Generates CSS w/ sourcemaps to lines in JS at runtime
MIT License
8 stars 4 forks source link

Add graceful handling of sourcemap fetch errors #20

Closed rtsao closed 5 years ago

rtsao commented 6 years ago

Resolves https://github.com/rtsao/css-to-js-sourcemap/issues/19

kahwee commented 5 years ago

Background:

You suggested in our conversation to try implementing setRequestInterception

And then run the same test on "/no-map", but for the "/external-map" route, where requests to the sourcemap files are intercepted and replaced with 5xx and/or 404 responses

I am currently stuck at a pending promise after setRequestInterception.

I tried to do this:

  const page = await browser.newPage();
  await page.setRequestInterception(true);
  let url = `http://localhost:${port}${route}`;
  await page.goto(url);
  page.on("console", msg => {
    Promise.all(msg.args().map(a => a.jsonValue())).then(async args => {
      if (args[0] === "__on_message__") {
        msgHandler(args[1]);
      } else if (args[0] === "Debug worker error") {
        errHandler(args[1]);
      }
    });
  });
  page.on("request", interceptedRequest => {
    interceptedRequest.continue();
  });

await page.setRequestInterception(true); never completes and I'm not sure how to continue from here.

I also tried upgrading to puppeteer v1.9.0 but that didn't work.

kahwee commented 5 years ago

Wow, thanks!