Skip to content

Commit

Permalink
fix: dont pass undefined options to fetch
Browse files Browse the repository at this point in the history
We're getting Sentry errors reporting `Cannot read properties of
undefined (reading 'headers')` originating from this fetch. This commit
checks we have fetchOptions before invoking fetch with the fetchOptions
otherwise only the path is used.
  • Loading branch information
mrloop committed Dec 19, 2023
1 parent b573b67 commit 78e36d4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
7 changes: 3 additions & 4 deletions ember-lottie/src/components/lottie.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,9 @@ export default class LottieComponent extends Component<LottieSignature> {
animationData = this.args.animationData;
} else if (this.args.path) {
try {
const response = await window.fetch(
this.args.path,
this.args.fetchOptions,
);
const response = await (this.args.fetchOptions
? window.fetch(this.args.path, this.args.fetchOptions)
: window.fetch(this.args.path));

if (response.status === 404) {
throw new NotFoundError();
Expand Down
6 changes: 1 addition & 5 deletions test-app/tests/integration/components/lottie-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,10 +252,6 @@ module('Integration | Component | lottie', function (hooks) {
/>
`);
const fetchArgs = fetch.getCall(0).args;
assert.deepEqual(
fetchArgs,
['/data.json', undefined],
'fetch arguments match',
);
assert.deepEqual(fetchArgs, ['/data.json'], 'fetch arguments match');
});
});

0 comments on commit 78e36d4

Please sign in to comment.