[adr] network handler behavior proposal#17685
Conversation
PR Summary by QodoADR: Define network handler disposition, ordering, and failure semantics Description
Diagram
High-Level Assessment
Files changed (1)
|
Code Review by Qodo
1. Wrong Python behavior claim
|
b09a2bc to
18895d1
Compare
|
Code review by qodo was updated up to the latest commit 18895d1 |
| network.add_request_handler { |r| r.remove_header("X-Test") } | ||
| ``` | ||
|
|
||
| 4. **Handlers with uncaught exceptions are not processed.** Handling proceeds as if the handler |
There was a problem hiding this comment.
Actually, maybe the right answer here is to make this user-toggled with the default being to raise. I didn't consider this when suggesting alternatives below. Perhaps we do want to error-by-default but provide a global escape hatch while things are still in draft.
There was a problem hiding this comment.
I feel fail fast should always be the right approach for people
There was a problem hiding this comment.
First, to clarify, Python as written does the error behavior in this ADR (except for it doesn't discard staged changes).
As for fast-fail, that's correct for synchronous code evaluating the behavior. In network handlers, the failures will come from things the author didn't write like third-party scripts, analytics beacons, favicon retries, an auth challenge from an unrelated CDN. We don't want to necessarily couple the test's pass/fail to the open internet via a still-under-development BiDi protocol.
The reason I don't love this proposal as written is because when a user wants to mutate a specific thing as the intent of the test, silently ignoring it is a real problem, but I also don't want to de facto require users to always wrap everything in a try/catch which seems like a bad experience.
Honestly the desired default behavior is going to be different if a user wants to observe vs mutate, which might be a good reason to support the differentiation earlier. The alternative would be an error handling toggle for propagate vs log
Last Fall we were discussing @p0deje's BiDi Protocol Design Document. If you read the comments on that doc, you'll see that @nvborisenko and I raised a bunch of concerns and suggested improvements. I did not submit a full counter proposal like I planned to, and we stopped having meetings to discuss it so nothing was resolved.
Binding Status
fail>provide_response>continue_response) with a continue_response override, rather than first-disposition (1,2) response has nofail(1); dispatch is FIFO (3); Sends mutated event when errors instead of discarding it (4); original event is not accessible, only mutated event (6); nocompleteimplementation (7); body not collected behind the handler (8).complete(7), user-managed body (8)completeimplementation (7), user-managed body (8); also noAddResponseHandlerAddRequestHandler/AddResponseHandlerAddRequestHandler/AddResponseHandler💥 What does this PR do?
This ADR represents my counter proposal to the document above, focusing on behaviors instead of implementation details (though an implementation I sketched out in Ruby does all these things).
I've spent a lot of time looking at edge cases and comparing things to Playwright to provide what I think is the best approach.
🔧 Implementation Notes
🤖 AI assistance
💡 Additional Considerations
🔄 Types of changes