Skip to content

Commit

Permalink
STCOR-759 return non-okapi request fetches as-is (#1369)
Browse files Browse the repository at this point in the history
Instead of catching errors from non-Okapi requests and converting them
to rejected promises, just `return fetch()` straight up, whatever that
response contains.

h/t @MikeTaylor for pointing me in this direction, and reading minified
code to try to suss the problem.

Refs STCOR-759, UILDP-129
  • Loading branch information
zburke authored Nov 9, 2023
1 parent 34a1b81 commit a323456
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
* Shrink the token lifespan so we are less likely to use an expired one. Refs STCOR-754.
* Correctly evaluate token lifespan; use consistent protocol for service worker messages. Refs STCOR-756.
* Allow console to be preserved on logout. STCOR-761.
* Do not catch and reject non-okapi request errors. Refs STCOR-759, UILDP-129.

## [10.0.0](https://github.com/folio-org/stripes-core/tree/v10.0.0) (2023-10-11)
[Full Changelog](https://github.com/folio-org/stripes-core/compare/v9.0.0...v10.0.0)
Expand Down
6 changes: 1 addition & 5 deletions src/service-worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -417,11 +417,7 @@ export const passThrough = (event, te, oUrl) => {

// default: pass requests through to the network
// console.log('-- (rtr-sw) passThrough NON-OKAPI', req.url)
return fetch(event.request, { credentials: 'include' })
.catch(e => {
console.error(e); // eslint-disable-line no-console
return Promise.reject(new Error(e));
});
return fetch(event.request);
};

/**
Expand Down
2 changes: 1 addition & 1 deletion src/service-worker.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ describe('passThrough', () => {
try {
await passThrough(event, tokenExpiration, oUrl);
} catch (e) {
expect(e).toMatchObject(new Error(error));
expect(e).toEqual(error);
}
});
});
Expand Down

0 comments on commit a323456

Please sign in to comment.