Do not clear errors after they are thrown (#12303)
Instead, to trigger a retry, the consumer should invalidate the cache. In the future, we will likely add a way to invalidate only the failed records.
Andrew Clark committed
Feb 27, 2018 at 20:02 UTC
86d04f6ea2896eca7a18792b8acc87322ae52711
2 files changed
+3
-6
packages/simple-cache-provider/src/SimpleCacheProvider.js
-3
@@ -194,9 +194,6 @@ export function createCache(invalidator: () => mixed): Cache {
194
default:
195
// The requested resource previously failed loading.
196
const error = record.error;
197
- const emptyRecord: EmptyRecord = (record: any);
198
- emptyRecord.status = 0;
199
- emptyRecord.error = null;
197
throw error;
198
}
199
},
packages/simple-cache-provider/src/__tests__/SimpleCacheProvider-test.js
+3
-3
@@ -71,15 +71,15 @@ describe('SimpleCacheProvider', () => {
71
expect(() => readUpperCase(cache, 'hello')).toThrow(error);
72
expect(error.message).toBe('oh no');
73
74
- // On a subsequent read, it should complete successfully.
74
+ // On a subsequent read, it should still throw.
75
try {
76
readUpperCase(cache, 'hello');
77
} catch (v) {
78
suspender = v;
79
}
80
await suspender;
81
- const result = readUpperCase(cache, 'hello');
82
- expect(result).toBe('HELLO');
81
+ expect(() => readUpperCase(cache, 'hello')).toThrow(error);
82
+ expect(error.message).toBe('oh no');
83
});
84
85
it('can preload data ahead of time', async () => {