Skip to content

Commit 7e7cfd3

Browse files
committed
fix(core): only reject navigation with errors
closes #153
1 parent ca149ef commit 7e7cfd3

File tree

9 files changed

+35
-20
lines changed

9 files changed

+35
-20
lines changed

.eslintrc.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ module.exports = {
3131
'prettier',
3232
'prettier/@typescript-eslint',
3333
'plugin:monorepo-cop/recommended',
34+
'plugin:import/errors',
35+
'plugin:import/warnings',
36+
'plugin:import/typescript',
3437
],
3538
plugins: ['monorepo-cop'],
3639
parserOptions: {
@@ -40,6 +43,11 @@ module.exports = {
4043
settings: {
4144
'import/core-modules': ['electron'],
4245
'import/external-module-folders': workspacesWithModules,
46+
'import/resolver': {
47+
typescript: {
48+
project: ['tsconfig.json', 'replay/tsconfig.json', 'replay/frontend/tsconfig.json'],
49+
},
50+
},
4351
},
4452
env: {
4553
node: true,

copyfiles.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// eslint-disable-next-line import/no-extraneous-dependencies
1+
// eslint-disable-next-line import/no-extraneous-dependencies,import/no-self-import
22
const copyfiles = require('copyfiles');
33
const Fs = require('fs');
44
const pkg = require('./package.json');

core-interfaces/ResourceType.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// eslint-disable-next-line import/no-extraneous-dependencies
12
import Protocol from 'devtools-protocol';
23
import Network = Protocol.Network;
34
import DevtoolsResourceType = Network.ResourceType;

core/lib/Tab.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -690,13 +690,6 @@ b) Use the UserProfile feature to set cookies for 1 or more domains before they'
690690
'Resource failed to load, but the reason was not provided by devtools.',
691691
);
692692
}
693-
if (
694-
resource.resourceType === 'Document' &&
695-
resource.browserRequestId === this.navigations.top?.browserRequestId &&
696-
this.navigations?.top?.resourceId?.isResolved === false
697-
) {
698-
this.navigations.top.navigationError = loadError;
699-
}
700693

701694
this.session.mitmRequestSession.browserRequestFailed({
702695
resource,
@@ -706,6 +699,7 @@ b) Use the UserProfile feature to set cookies for 1 or more domains before they'
706699

707700
const resources = this.sessionState.getBrowserRequestResources(event.resource.browserRequestId);
708701
if (resources?.length) {
702+
// this function will resolve any pending resourceId for a navigation
709703
this.sessionState.captureResourceError(
710704
this.id,
711705
MitmRequestContext.toEmittedResource({ id: resources[0].resourceId, ...resource } as any),

core/lib/TabNavigations.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -136,11 +136,11 @@ export default class TabNavigations extends TypedEventEmitter<TabNavigationEvent
136136
currentUrl: this.currentUrl,
137137
});
138138
if (!this.top || this.top.resourceId.isResolved) return;
139-
if (statusCode >= 400 || error) {
140-
// since we don't know if there are listeners yet, we need to just set the error on the return value
141-
// otherwise, get unhandledrejections
142-
this.top.navigationError = error ?? new Error('Failed to load url');
143-
}
139+
140+
// since we don't know if there are listeners yet, we need to just set the error on the return value
141+
// otherwise, get unhandledrejections
142+
if (error) this.top.navigationError = error;
143+
144144
this.top.resourceId.resolve(resourceId);
145145
}
146146

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,16 @@
5353
"eslint": "^7.14.0",
5454
"eslint-config-airbnb-typescript": "^12.0.0",
5555
"eslint-config-prettier": "^6.15.0",
56-
"eslint-plugin-monorepo-cop": "^1.0.2",
56+
"eslint-import-resolver-typescript": "^2.3.0",
5757
"eslint-plugin-eslint-comments": "^3.2.0",
5858
"eslint-plugin-import": "^2.22.1",
5959
"eslint-plugin-jest": "^24.1.3",
60-
"eslint-plugin-react": "^7.21.5",
61-
"eslint-plugin-react-hooks": "^4.2.0",
6260
"eslint-plugin-jsx-a11y": "^6.4.1",
61+
"eslint-plugin-monorepo-cop": "^1.0.2",
6362
"eslint-plugin-prettier": "^3.1.4",
6463
"eslint-plugin-promise": "^4.2.1",
64+
"eslint-plugin-react": "^7.21.5",
65+
"eslint-plugin-react-hooks": "^4.2.0",
6566
"husky": "^4.3.0",
6667
"jest": "^26.6.3",
6768
"jest-environment-node": "^26.6.2",

puppet/lib/BrowserFetcher.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import * as https from 'https';
2323
import * as http from 'http';
2424

2525
import * as extractZip from 'extract-zip';
26-
import removeRecursive from 'rimraf';
26+
import * as removeRecursive from 'rimraf';
2727
import * as URL from 'url';
2828
import { HttpsProxyAgent, HttpsProxyAgentOptions } from 'https-proxy-agent';
2929
import { getProxyForUrl } from 'proxy-from-env';

puppet/lib/EngineInstaller.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as os from 'os';
2-
import ProgressBar from 'progress';
2+
import * as ProgressBar from 'progress';
33
import { BrowserFetcher } from './BrowserFetcher';
4-
import { getInstallDirectory } from "./browserPaths";
4+
import { getInstallDirectory } from './browserPaths';
55

66
export default class EngineInstaller {
77
constructor(readonly engine: { browser: string; revision: string }) {}

yarn.lock

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7860,6 +7860,17 @@ eslint-import-resolver-node@^0.3.4:
78607860
debug "^2.6.9"
78617861
resolve "^1.13.1"
78627862

7863+
eslint-import-resolver-typescript@^2.3.0:
7864+
version "2.3.0"
7865+
resolved "https://registry.yarnpkg.com/eslint-import-resolver-typescript/-/eslint-import-resolver-typescript-2.3.0.tgz#0870988098bc6c6419c87705e6b42bee89425445"
7866+
integrity sha512-MHSXvmj5e0SGOOBhBbt7C+fWj1bJbtSYFAD85Xeg8nvUtuooTod2HQb8bfhE9f5QyyNxEfgzqOYFCvmdDIcCuw==
7867+
dependencies:
7868+
debug "^4.1.1"
7869+
glob "^7.1.6"
7870+
is-glob "^4.0.1"
7871+
resolve "^1.17.0"
7872+
tsconfig-paths "^3.9.0"
7873+
78637874
eslint-module-utils@^2.6.0:
78647875
version "2.6.0"
78657876
resolved "https://registry.yarnpkg.com/eslint-module-utils/-/eslint-module-utils-2.6.0.tgz#579ebd094f56af7797d19c9866c9c9486629bfa6"
@@ -9286,7 +9297,7 @@ glob-to-regexp@^0.3.0:
92869297
resolved "https://registry.yarnpkg.com/glob-to-regexp/-/glob-to-regexp-0.3.0.tgz#8c5a1494d2066c570cc3bfe4496175acc4d502ab"
92879298
integrity sha1-jFoUlNIGbFcMw7/kSWF1rMTVAqs=
92889299

9289-
glob@^7.0.0, glob@^7.0.3, glob@^7.0.5, glob@^7.1.1, glob@^7.1.2, glob@^7.1.3, glob@^7.1.4, glob@~7.1.1:
9300+
glob@^7.0.0, glob@^7.0.3, glob@^7.0.5, glob@^7.1.1, glob@^7.1.2, glob@^7.1.3, glob@^7.1.4, glob@^7.1.6, glob@~7.1.1:
92909301
version "7.1.6"
92919302
resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.6.tgz#141f33b81a7c2492e125594307480c46679278a6"
92929303
integrity sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==

0 commit comments

Comments
 (0)