Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Flight] Add getCacheForType() to the dispatcher #20315

Merged
merged 13 commits into from
Dec 3, 2020
Prev Previous commit
Next Next commit
Add some error coverage and retry
  • Loading branch information
gaearon committed Dec 3, 2020
commit a92435e165d7eda5629f340c5cc72c617fd198fb
14 changes: 14 additions & 0 deletions packages/react-fetch/src/__tests__/ReactFetchNode-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,18 @@ describe('ReactFetchNode', () => {
});
expect(outputs).toMatchObject(['banana', 'mango', 'orange']);
});

// @gate experimental
it('can produce an error', async () => {
serverImpl = (req, res) => {};

expect.assertions(1);
try {
await waitForSuspense(() => {
return fetch('BOOM');
});
} catch (err) {
expect(err.message).toEqual('Invalid URL: BOOM');
}
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export function waitForSuspense<T>(fn: () => T): Promise<T> {
resolve(result);
} catch (thrownValue) {
if (typeof thrownValue.then === 'function') {
thrownValue.then(retry, reject);
thrownValue.then(retry, retry);
} else {
reject(thrownValue);
}
Expand Down