Skip to content

Commit

Permalink
Ensure archive URLs object still exists, since network could have bee…
Browse files Browse the repository at this point in the history
…n idle before this
  • Loading branch information
skitterm committed Jul 16, 2024
1 parent 65accc0 commit d986ff8
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/cypress/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,11 @@ const setupNetworkListener = async ({
onRequest: (url) => {
networkIdleWatcher.onRequest(url);
// gather all the requests that went out, so we can archive even the cached resources
testSpecificArchiveUrls[testId].push(url);
// it's possible requests are sent out after we're done waiting for the test (and we delete `testSpecificArchiveUrls`
// when that happens), so ensure it still exists first.
if (testSpecificArchiveUrls[testId]) {
testSpecificArchiveUrls[testId].push(url);
}
},
// important that we don't directly pass networkIdleWatcher.onResponse here,
// as that'd bind `this` in that method to the ResourceArchiver
Expand Down Expand Up @@ -172,6 +176,7 @@ const saveArchives = (archiveInfo: WriteParams & { testId: string }) => {
// remove archives off of object after write them
delete resourceArchivers[testId];
// clean up now-unneeded objects
console.log('deleting', testId);

Check warning on line 179 in packages/cypress/src/index.ts

View workflow job for this annotation

GitHub Actions / test / test

Unexpected console statement
delete testSpecificArchiveUrls[testId];
delete networkIdleWatchers[testId];
return writeArchives({ ...rest, resourceArchive: finalArchive }).then(() => {
Expand Down

0 comments on commit d986ff8

Please sign in to comment.