-
Notifications
You must be signed in to change notification settings - Fork 174
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
Fix infinite loop when the typescript client requests a non-existing table #1876
Comments
Are there any other cases where a |
I'm not sure why we special-case the 400 there — 409 is the code we use to tell the client to refetch. In general 4xx codes are a user error so the client should just throw ann error and quit. But yeah, to your point, we need to do two things — return 404 from the server for non-existing tables and don't special case the 400 status code. |
We used a 400 initially on the server to not specialize the reasons. I guess things have evolved. |
One related problem is that the constructor makes the first fetch call, so non-actionable errors can't be caught. We should change the client to separate resource creation (i.e. constructor) from connection initialisation ( |
I agree, I think we should open a new issue about this in particular. I've opened #1880 that should fix this immediate issue of infinite loops. As an aside, I don't think we should be returning 404 errors since as far as we're concerned any request that defines a shape that is not valid (inexistent or invalid root table, inexistent or invalid column names, mismatched shape id and definition) are badly formed requests, and thus 400s. If we want to split out errors (e.g. missing table from PG is 404, invalid table name is 400), it would be perhaps more explicit and informative but the handling from our side would be exactly the same, so it would just be a matter of improving API semantics. |
Fixes #1876 The issue was that we were sending `must-refetch` messages with some of our 400s, although they were unrecoverable and re-fetching would trigger an infinite loop. I've made the server send 400 errors for the cases where the `shape_id` and `shape_definition` do not match, with an explanatory message, and I've made the client terminate when receiving such an error. As a temporary measure, the error is not thrown into the ether but stored in the `ShapeStream` (accessible via `stream.error`). We have had some discussions with @balegas about making errors more "handleable" by changing our approach to the `ShapeStream` instantiation. I think this warrants opening a new issue and corresponding PR to discuss more thoroughly.
Fixes #1876 The issue was that we were sending `must-refetch` messages with some of our 400s, although they were unrecoverable and re-fetching would trigger an infinite loop. I've made the server send 400 errors for the cases where the `shape_id` and `shape_definition` do not match, with an explanatory message, and I've made the client terminate when receiving such an error. As a temporary measure, the error is not thrown into the ether but stored in the `ShapeStream` (accessible via `stream.error`). We have had some discussions with @balegas about making errors more "handleable" by changing our approach to the `ShapeStream` instantiation. I think this warrants opening a new issue and corresponding PR to discuss more thoroughly.
The server returns a 400 and this line then restarts the fetching
electric/packages/typescript-client/src/client.ts
Line 235 in 371dc56
It seems 404 is the proper response code for the server and would fix this issue.
The text was updated successfully, but these errors were encountered: