mirror of
https://github.com/4gray/iptvnator.git
synced 2026-10-08 17:06:15 -08:00
The renderer was reading session.id and forwarding it to the addon, but during the loading window that id is the placeholder "embedded-mpv-starting" set by createLoadingSession. If the user adjusted volume, seeked, or toggled audio/subtitle/speed/aspect before the addon's createSession returned the real id, that placeholder id reached the addon — and the addon's getSessionOrThrow threw a raw std::runtime_error which libc++abi terminated the process on. Two fixes, defense in depth: 1. Renderer (session controller): use the canonical sessionId() signal, which is null until the addon hands back a real id, as the gate for all IPC calls. Wrap every IPC call in a guardIpc helper that swallows addon-side throws so a torn-down session or race won't surface as an uncaught promise rejection. 2. Native (embedded_mpv.mm): change getSessionOrThrow to take a Napi::Env and throw Napi::Error::New(env, ...) instead of std::runtime_error. node-addon-api converts Napi::Error to a JS exception cleanly; the previous std::runtime_error escaped the C++ frame and aborted the process when the addon was built without NAPI_CPP_EXCEPTIONS translation. Refactor splits findSession (returns nullptr) from getSessionOrThrow (env-aware) so call paths that just probe a session's existence don't pay the throw cost. The native fix needs an addon rebuild to take effect; the renderer fix prevents the crash trigger immediately. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Entire-Checkpoint: f957cd9849e0