Repository navigation
Conversation
…lien-cpsn#209 When the post-request script failed, the HTTP, WebSocket and MQTT senders returned the error before marking the request as finished, so the TUI showed it as pending until ATAC was restarted. The script's console output was also thrown away, so the "(CONSOLE)" error pointed at an empty or stale console. The request is now marked as finished before the script error is returned, the script error is kept as the post-request console output, and the CLI prints it with --console.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #209.
When the post-request script failed,
send_http_request,send_ws_requestandsend_mqtt_requestreturned the error with?before the lines that setis_pending = falseand replace the cancellation token. The TUI then kept the request pending, and pressing send again only cancelled a token nobody was waiting on, so the request stayed stuck until ATAC was restarted.The script's console output was also dropped on that path, so the
(CONSOLE) POST-SCRIPT ERRORmessage pointed at an empty console, or at the output of an earlier run.Changes:
handle_post_request_scriptnow returns the console output next to the result, so it is kept when the script fails (the same wayhandle_pre_request_scriptkeeps the pre-request output).atac request send --consoleprints the post-request console output when the script fails, like it already does for a failing pre-request script.Tests: one
#[tokio::test]per protocol (failing_post_request_script_does_not_leave_the_request_pending). HTTP uses a one-shot localTcpListenerthat answers 200. WebSocket and MQTT connect to a closed local port, so the script runs on the error response. Each test checks that the request is no longer pending and that the console output contains the script error. All three fail onmainwithassertion failed: !request.is_pending.What was run:
cargo test: 40 passed (37 before plus the 3 new ones).cargo clippy --all-targets: same warning count asmain(291). The existingdigest.rs:381string-indexing error is onmaintoo.python3 -m http.server, with a post-request script that throws:atac -d <dir> request send c/r --console --dry-runnow prints the JavaScript error before(CONSOLE) POST-SCRIPT ERROR. Onmainit printed only the error line.Not run: the TUI by hand. The tests cover the request state the TUI reads (
is_pending,console_output).Not covered here: two other early returns leave a request pending the same way, and this PR does not change them. One is a WebSocket upgrade the server refuses (for example a 404 answer). A local check gave
websocket upgrade failedwithis_pendingstilltrue. The other isCouldNotDecodeResponsein the HTTP sender. Both can go in a follow-up if wanted.