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

chore: extract Request and Response into its own module #5861

Conversation

christian-bromann
Copy link
Contributor

Continuing with the effort of #5856 splitting classes into their own modules.

@christian-bromann christian-bromann force-pushed the cb-splitting-up-files-request-response branch from 28745e6 to f88fd0c Compare May 13, 2020 09:42
@christian-bromann christian-bromann force-pushed the cb-splitting-up-files-request-response branch from f88fd0c to f7691e7 Compare May 13, 2020 09:44
Copy link
Collaborator

@jackfranklin jackfranklin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, thank you!

@@ -274,8 +275,7 @@ export class NetworkManager extends EventEmitter {
const response = new Response(this._client, request, responsePayload);
request._response = response;
request._redirectChain.push(request);
response._bodyLoadedPromiseFulfill.call(
null,
response._resolveBody(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@christian-bromann is this change deliberate? Looks like we lost a call to ._bodyLoadedPromiseFulfill.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jackfranklin when making _bodyLoadedPromiseFulfill a private field we can't access it from NetworkManager anymore. I created a method in the Response class to allow access to it.

  _resolveBody(err: Error | null): void {
    return this._bodyLoadedPromiseFulfill(err);
  }

Alternatively I could just keep _bodyLoadedPromiseFulfill as non private field.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah got you, thanks for explaining. As a general rule I think we should just do the easy privatisation work and leave any others as non private when initially splitting classes out (just to keep changes per PR down) but in this case this all looks fine to me and CI is green so no need to undo any of it 👍

@jackfranklin jackfranklin merged commit 39f1b13 into puppeteer:master May 13, 2020
@christian-bromann christian-bromann deleted the cb-splitting-up-files-request-response branch May 13, 2020 13:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants