Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A proxied request hangs if a request to the original site emits an error #1961

Closed
AndreyBelym opened this issue Mar 13, 2019 · 4 comments
Closed
Labels
Milestone

Comments

@AndreyBelym
Copy link
Contributor

AndreyBelym commented Mar 13, 2019

I don't know if this can be reproduced in production, but likely it can.

Take a looks at the error handlers of the DestinationRequest's req object:

_onError at src/request-pipeline/destination-request/index.ts

    _onError (err: Error): void {
        if (this._isSocketHangUpErr(err))
            this.emit('socketHangUp');

        else if (requestAgent.shouldRegressHttps(err, this.opts)) {
            requestAgent.regressHttps(this.opts);
            this._send();
        }

        else if (this._isTunnelingErr(err)) {
            //...
        }

        else if (this._isDNSErr(err)) {
            //...  
        }

        else
            this.emit('error', err);
    }

error at src/request-pipeline/utils.ts

    req.on('error', () => {
        ctx.hasDestReqErr = true;
        resolve();
    });

If an error can't be handled by any brach in the _onError handler, it will be handled by the generic error handler, that just sets the ctx.hasDestReqErr and doesn't set the ctx.goToNextStage flag. After that the first flag is not handled by any code because without the second request pipeline silently terminates here just after the request is resolved.

How to reproduce:

  1. (optional) Add logging statements or breakpoints:
    test/playground/server.js:24
    src/request-pipeline/index.ts:210
    src/request-pipeline/utils.ts:95
    src/request-pipeline/destination-request/index.ts:171

  2. npm i nock

  3. Create test.js:

const nock = require('nock');
const playground = require('./test/playground/server');

nock('http://example.com')
    .get('/')
    .replyWithError('this fails')
    .persist();

playground.start();
  1. node test.js
  2. When a browser opens, open DevTools.
  3. Proxy example.com.
  4. Request to the proxied page started and never finishes, no error is logged in handlePageError at test/playground/server.js
@gal432
Copy link

gal432 commented Mar 19, 2019

I think that is what I am dealing with in this ticket

@gal432
Copy link

gal432 commented Mar 26, 2019

any updates about the problem?

@AlexSkorkin
Copy link
Contributor

No updates yet. You will be automatically notified once we make progress.

@LavrovArtem LavrovArtem added this to the Planned milestone May 21, 2019
@LavrovArtem LavrovArtem modified the milestones: Planned, Sprint #50 Jan 28, 2020
@AndreyBelym AndreyBelym modified the milestones: Sprint #50, Sprint #51 Feb 7, 2020
LavrovArtem added a commit to LavrovArtem/testcafe-hammerhead that referenced this issue Feb 10, 2020
LavrovArtem added a commit to LavrovArtem/testcafe-hammerhead that referenced this issue Feb 10, 2020
@lock
Copy link

lock bot commented Feb 21, 2020

This thread has been automatically locked since it is closed and there has not been any recent activity. Please open a new issue for related bugs or feature requests. We recommend you ask TestCafe API, usage and configuration inquiries on StackOverflow.

@lock lock bot added the STATE: Auto-locked Issues that were automatically locked by the Lock bot label Feb 21, 2020
@lock lock bot locked as resolved and limited conversation to collaborators Feb 21, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants