Mirror: The highly customizable and versatile GraphQL client with which you add on features like normalized caching as you grow.
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Fix cascading cancellations from components (#503)

* Fix cascading cancellations from components

wonka@^4.0.0 has some improved behaviour that fixed
some edge cases and bugs. As it turned out urql was
relying on one of them.
The switchMap in the hooks would cancel the last
query and start the next. However, this cancellation
cascades not only up to executeQuery to end and
teardown the operation, it also flows up through the
exchange pipeline, ending the entire thing like an
electrical surge.

This can be prevented by publishing the results
chain and making sure it can never be interrupted.

* Fix pollInterval test

* Add scheduler dependency to silence peer dependency warning

authored by

Phil Plückthun and committed by
GitHub
21ed7734 c3804485

+11 -4
+1 -1
package.json
··· 127 127 "rollup-plugin-replace": "^2.2.0", 128 128 "rollup-plugin-terser": "^5.1.3", 129 129 "rollup-plugin-typescript2": "^0.25.3", 130 - "scheduler": "^0.18.0", 131 130 "terser": "^4.6.2", 132 131 "ts-jest": "^24.3.0", 133 132 "typescript": "^3.7.4" ··· 137 136 "react": ">= 16.8.0" 138 137 }, 139 138 "dependencies": { 139 + "scheduler": ">= 0.16.0", 140 140 "react-wonka": "^2.0.0", 141 141 "wonka": "^4.0.5" 142 142 }
+4 -2
src/client.test.ts
··· 195 195 196 196 expect(receivedOps.length).toEqual(1); 197 197 jest.advanceTimersByTime(200); 198 - expect(receivedOps.length).toEqual(3); 198 + expect(receivedOps.length).toEqual(5); 199 199 expect(receivedOps[0].operationName).toEqual('query'); 200 - expect(receivedOps[1].operationName).toEqual('query'); 200 + expect(receivedOps[1].operationName).toEqual('teardown'); 201 201 expect(receivedOps[2].operationName).toEqual('query'); 202 + expect(receivedOps[3].operationName).toEqual('teardown'); 203 + expect(receivedOps[4].operationName).toEqual('query'); 202 204 unsubscribe(); 203 205 }); 204 206 });
+5
src/client.ts
··· 28 28 interval, 29 29 fromValue, 30 30 switchMap, 31 + publish, 31 32 } from 'wonka'; 32 33 33 34 import { ··· 135 136 forward: fallbackExchangeIO, 136 137 })(this.operations$) 137 138 ); 139 + 140 + // Prevent the `results$` exchange pipeline from being closed by active 141 + // cancellations cascading up from components 142 + pipe(this.results$, publish); 138 143 } 139 144 140 145 private createOperationContext = (
+1 -1
yarn.lock
··· 5137 5137 resolved "https://registry.yarnpkg.com/sax/-/sax-1.2.4.tgz#2816234e2378bddc4e5354fab5caa895df7100d9" 5138 5138 integrity sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw== 5139 5139 5140 - scheduler@^0.18.0: 5140 + "scheduler@>= 0.16.0", scheduler@^0.18.0: 5141 5141 version "0.18.0" 5142 5142 resolved "https://registry.yarnpkg.com/scheduler/-/scheduler-0.18.0.tgz#5901ad6659bc1d8f3fdaf36eb7a67b0d6746b1c4" 5143 5143 integrity sha512-agTSHR1Nbfi6ulI0kYNK0203joW2Y5W4po4l+v03tOoiJKpTBbxpNhWDvqc/4IcOw+KLmSiQLTasZ4cab2/UWQ==