Skip to content

Commit

Permalink
Fix: Error in onLoadingFailed
Browse files Browse the repository at this point in the history
Fix #469
  • Loading branch information
qczhou authored and alrra committed Sep 2, 2017
1 parent 79b8da5 commit d389912
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/lib/connectors/jsdom/jsdom.ts
Expand Up @@ -210,6 +210,7 @@ class JSDOMConnector implements IConnector {

// TODO: Replace `null` with `resource` once it
// can be converted to `JSDOMAsyncHTMLElement`.
// Event is also emitted when status code in response is not 200.
await this._server.emitAsync('fetch::end', fetchEndEvent);

return callback(null, resourceNetworkData.response.body.content);
Expand Down Expand Up @@ -368,6 +369,7 @@ class JSDOMConnector implements IConnector {
response: this._targetNetworkData.response
};

// Event is also emitted when status code in response is not 200.
await this._server.emitAsync('targetfetch::end', fetchEnd);

jsdom.env({
Expand Down
5 changes: 3 additions & 2 deletions src/lib/connectors/shared/remote-debugging-connector.ts
Expand Up @@ -233,7 +233,7 @@ export class Connector implements IConnector {
}

if (params.type === 'Manifest') {
const { request: { url: resource } } = this._requests.get(params.requestId);
const { request: { url: resource } } = request;
const event: IManifestFetchError = {
error: new Error(params.errorText),
resource
Expand All @@ -254,7 +254,7 @@ export class Connector implements IConnector {

debug(`Error found:\n${JSON.stringify(params)}`);
const element: AsyncHTMLElement = await this.getElementFromRequest(params.requestId);
const { request: { url: resource } } = this._requests.get(params.requestId);
const { request: { url: resource } } = request;
const eventName: string = this._href === resource ? 'targetfetch::error' : 'fetch::error';

const hops: Array<string> = this._redirects.calculate(resource);
Expand Down Expand Up @@ -382,6 +382,7 @@ export class Connector implements IConnector {
* to avoid emitting duplidate events.
*/
if (!this.rootFaviconRequestOrResponse(params)) {
/** Event is also emitted when status code in response is not 200. */
await this._server.emitAsync(eventName, data);
}

Expand Down

0 comments on commit d389912

Please sign in to comment.