Account-Link / teleport-gramine-rs

One-time programs on X, create and share a one-time post link from your Twitter account with LLM-enforced policies
https://teleport.best/
MIT License
66 stars 9 forks source link

NFT event subscribe is not robust #15

Closed amiller closed 1 month ago

amiller commented 1 month ago

If the subscribe loop crashes, then it reaches a zombie state.

NFTs can be minted by the backend, but they fail to be promoted from “pending” to ready. Then they can’t be spent at all even if the backend restarts.

The subscribe loop failing seems to happen occasionally when a tweet response fails to decode.

Example log message:

2024-09-11T22:12:48Z INFO  alloy_pubsub::service] Pubsub service request channel closed. Shutting down.
called `Result::unwrap()` on an `Err` value: error decoding response body: missing field `data` at line 1 column 112
Caused by:
    missing field `data` at line 1 column 112
Location:
    src/twitter.rs:110:45
stack backtrace:
   0:          0xbc67ef5 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h1b9dad2a88e955ff
   1:          0xbc8e33b - core::fmt::write::h4b5a1270214bc4a7
   2:          0xbc64eff - std::io::Write::write_fmt::hd04af345a50c312d
   3:          0xbc691f1 - std::panicking::default_hook::{{closure}}::h96ab15e9936be7ed
   4:          0xbc68ecc - std::panicking::default_hook::h3cacb9c27561ad33
   5:          0xbc69851 - std::panicking::rust_panic_with_hook::hfe205f6954b2c97b
   6:          0xbc696b7 - std::panicking::begin_panic_handler::{{closure}}::h6cb44b3a50f28c44
...
amiller commented 1 month ago

i thought missing data field is in nft event subscribe, but it could be this line... an uncaught error here would indeed crash the pubsub thread https://github.com/Account-Link/teleport-gramine-rs/blob/591a6c16c5801e3679addc532c5ee0351f41c8c2/src/twitter.rs#L110

amiller commented 1 month ago

[2024-09-13T12:21:14Z INFO teleport::oai] gpt-4o response: "safe" thread 'tokio-runtime-worker' panicked at src/twitter.rs:111:6: Failed to parse SendTweetResponse: "{\"detail\":\"You are not permitted to perform this action.\",\"type\":\"about:blank\",\"title\":\"Forbidden\",\"status\": 403}": Error("missing field data", line: 1, column: 112)

amiller commented 1 month ago

Fixed in #17