stencil icon indicating copy to clipboard operation
stencil copied to clipboard

Request is already handled!

Open PhorkysXT opened this issue 6 years ago • 5 comments

Stencil version:

 @stencil/[email protected]

I'm submitting a: [x] bug report [ ] feature request [ ] support request

Current behavior: As already stated in #1567 there is a problem when using the request interceptor capability on E2EPages before .setContent()

We need the request interceptor before the web-components lifecycle sets in.

Result: Error: Request is already handled! at assert (C:...\node_modules\puppeteer-core\lib\helper.js:270:11) at Request.continue (C:...\node_modules\puppeteer-core\lib\NetworkManager.js:433:5) at Request. (C:...\node_modules\puppeteer-core\lib\helper.js:112:23) at Page. (C:...\node_modules@stencil\core\testing\index.js:32556:40) at Page.emit (events.js:327:22) at NetworkManager. (C:...\node_modules\puppeteer-core\lib\Page.js:110:68) at NetworkManager.emit (events.js:315:20) at NetworkManager._onRequest (C:...\node_modules\puppeteer-core\lib\NetworkManager.js:240:10) at NetworkManager._onRequestWillBeSent (C:...\node_modules\puppeteer-core\lib\NetworkManager.js:173:14) at CDPSession.emit (events.js:315:20) -- ASYNC -- at Request. (C:...\node_modules\puppeteer-core\lib\helper.js:111:15) at Page. (C:...\node_modules@stencil\core\testing\index.js:32556:40) at Page.emit (events.js:327:22) at NetworkManager. (C:...\node_modules\puppeteer-core\lib\Page.js:110:68) at NetworkManager.emit (events.js:315:20) at NetworkManager._onRequest (C:...\node_modules\puppeteer-core\lib\NetworkManager.js:240:10) at NetworkManager._onRequestWillBeSent (C:...\node_modules\puppeteer-core\lib\NetworkManager.js:173:14) at CDPSession.emit (events.js:315:20) at CDPSession._onMessage (C:...\node_modules\puppeteer-core\lib\Connection.js:200:12) at Connection._onMessage (C:...\node_modules\puppeteer-core\lib\Connection.js:112:17)

Expected behavior: Stencil should not interfere with any request interceptors set by our tests.

Steps to reproduce:

    await page.setRequestInterception(true);
    page.on('request', (request) =>{
      request.continue();
    });

    await page.setContent('<my-component></my-component>'
    );
    await page.waitForChanges();

Other information: Prior Issue report: https://github.com/ionic-team/stencil/issues/1567 Prior fix attempt: https://github.com/ionic-team/stencil/pull/1568/files

PhorkysXT avatar Apr 20 '20 09:04 PhorkysXT

We encourage you use the html option, of newSpecPage, try to avoid using page.on('request'). However, we recently merged some fixes around that, so maybe it helped!

manucorporat avatar May 06 '20 20:05 manucorporat

@manucorporat could you elaborate on how html of newSpecPage helps in an E2E scenario?

I tried page.on('request', ...) with 1.13.0-4 and still run into the Request is already handled! issue. 😕

luchsamapparat avatar May 08 '20 08:05 luchsamapparat

@manucorporat Tested 1.13.0-4 and the issue still persists.

As our application provides vital social security services to about 3 million customers we want to achieve a higher standard of testing.

Of cource we are using SpecPage to test as many things as possible, but that does not replace E2EPage tests.

Unfortunately we have to use mocks in our E2EPage tests and the only way that we could think of (without touching the application) is to forward requests by using the requestInterceptor mechanism.

Appreciate your help.

Best regards, PhorkysXT

PhorkysXT avatar May 11 '20 06:05 PhorkysXT

Hi @manucorporat, I have same question as @luchsamapparat any particular explanation how html option of newSpecPage would help? Is this documented somewhere?

I'm also curious what kind of fixes were merged to fix page.on('request').

Kind regards

laureanray avatar Aug 16 '22 08:08 laureanray

We encourage you use the html option, of newSpecPage, try to avoid using page.on('request'). However, we recently merged some fixes around that, so maybe it helped!

How exactly does that answer close this issue?

codearmadillo avatar Aug 25 '22 13:08 codearmadillo