fix: Strengthen error handling in qwenOAuth2.ts to prevent unhandled 'error' event#3481
Conversation
| @@ -8,7 +8,7 @@ import crypto from 'crypto'; | |||
| import path from 'node:path'; | |||
| import { promises as fs } from 'node:fs'; | |||
| import * as os from 'os'; | |||
There was a problem hiding this comment.
[Suggestion] ChildProcess is only used as a type here, so this should be a type-only import to satisfy the repo's lint rule.
| import * as os from 'os'; | |
| import type { ChildProcess } from 'node:child_process'; |
— gpt-5.4 via Qwen Code /review
|
Hi @wenshao, This PR contains the robust error handling fix for Status: ✅ Lint Fixed: Updated This addresses the root cause of the crash you identified. It is designed to be merged alongside PR #1675 (which handles the utility/test updates). Ready for your final approval! |
…her (#1675) - secure-browser-launcher now logs the URL and resolves instead of throwing when all browser commands fail, preventing callers from crashing on headless or minimal Linux environments - Add microsoft-edge to the Linux fallback list - Update JSDoc to match the new log-and-resolve contract - Pin test platform to darwin so the assertion doesn't get masked by the Linux fallback chain Note: this PR stabilizes the utility but does not by itself fix the RISC-V/OrangePi crash in #1674, which originates from the `open` npm package in qwenOAuth2.ts. See #3481 for the root-cause fix.
wenshao
left a comment
There was a problem hiding this comment.
No issues found. LGTM! ✅ — gpt-5.4 via Qwen Code /review
…her (#1675) - secure-browser-launcher now logs the URL and resolves instead of throwing when all browser commands fail, preventing callers from crashing on headless or minimal Linux environments - Add microsoft-edge to the Linux fallback list - Update JSDoc to match the new log-and-resolve contract - Pin test platform to darwin so the assertion doesn't get masked by the Linux fallback chain Note: this PR stabilizes the utility but does not by itself fix the RISC-V/OrangePi crash in #1674, which originates from the `open` npm package in qwenOAuth2.ts. See #3481 for the root-cause fix.
…her (QwenLM#1675) - secure-browser-launcher now logs the URL and resolves instead of throwing when all browser commands fail, preventing callers from crashing on headless or minimal Linux environments - Add microsoft-edge to the Linux fallback list - Update JSDoc to match the new log-and-resolve contract - Pin test platform to darwin so the assertion doesn't get masked by the Linux fallback chain Note: this PR stabilizes the utility but does not by itself fix the RISC-V/OrangePi crash in QwenLM#1674, which originates from the `open` npm package in qwenOAuth2.ts. See QwenLM#3481 for the root-cause fix.
…'error' event (QwenLM#3481) * fix: strengthen error handling in launchBrowser to prevent unhandled events * fix: strengthen error handling with ChildProcess type and debugLogger * fix: use type-only import for ChildProcess
Hi @wenshao,
As suggested in your review of #1675, this PR addresses the root cause of the crash reported in issue #1674
The Issue
The crash (
Unhandled 'error' event) occurs inpackages/core/src/qwen/qwenOAuth2.tswhen theopenpackage fails to spawn a browser process (common on RISC-V/OrangePi headless environments).The Fix
I updated the
launchBrowserhelper function to:childProcessis valid before attaching listeners.childProcess.on('error')listener immediately afterawait open()to minimize race conditions.try/catchAND the event listener, logging gracefully viadebugLoggerinstead of crashing.This implements your suggestion to "attach the error listener before the child has a chance to emit."
Relation to PR #1675
This is the second part of the split you requested:
qwenOAuth2.ts.--
(Fixes #1674)
Ready for review!