Skip to content

Comments

Ignore cancelled OpenAI dashboard navigation errors (-999)#409

Closed
spirosrap wants to merge 4 commits intosteipete:mainfrom
spirosrap:fix-openai-web-ignore-cancelled-navigation
Closed

Ignore cancelled OpenAI dashboard navigation errors (-999)#409
spirosrap wants to merge 4 commits intosteipete:mainfrom
spirosrap:fix-openai-web-ignore-cancelled-navigation

Conversation

@spirosrap
Copy link
Contributor

Summary

  • ignore NSURLErrorCancelled (-999) in OpenAI dashboard WKWebView navigation delegate callbacks
  • keep treating all other navigation errors as failures
  • add focused tests for ignored vs non-ignored navigation errors
  • mark helper as nonisolated so tests can call it without actor isolation issues

Why

WKWebView can emit NSURLErrorCancelled during expected navigation transitions. Treating that as a hard failure surfaces a misleading error in Codex/OpenAI credits fetch.

Fixes #262

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f91f13a70a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines 22 to 24
if Self.shouldIgnoreNavigationError(error) {
return
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Complete navigation on ignored cancel errors

Returning early on NSURLErrorCancelled means the delegate never calls completeOnce, so prepareWebView’s checked continuation in Sources/CodexBarCore/OpenAIWeb/OpenAIDashboardWebViewCache.swift can remain suspended forever when cancellation is terminal (i.e., no follow-up didFinish/didFail arrives after the cancel). In that case acquire(...) never returns and the higher-level dashboard timeout logic is bypassed because its deadline is started only after makeWebView completes.

Useful? React with 👍 / 👎.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in 375de22. Ignored NSURLErrorCancelled now completes the delegate continuation with success (instead of returning early), so prepareWebView cannot hang waiting for a callback. Added a focused test in OpenAIDashboardNavigationDelegateTests to cover cancelled-failure completion behavior.

@ratulsarna
Copy link
Collaborator

@codex review

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 375de2247b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".


func webView(_ webView: WKWebView, didFail navigation: WKNavigation!, withError error: Error) {
if Self.shouldIgnoreNavigationError(error) {
self.completeOnce(.success(()))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Don't mark cancelled navigations as completed success

Calling completeOnce(.success(())) for NSURLErrorCancelled in the failure delegates turns an intermediate cancellation into a terminal success. In this class, hasCompleted then suppresses all later callbacks, so a redirect-driven -999 can cause prepareWebView to resume before the real navigation finishes (or before a later hard failure), which can lead to scraping stale/partial dashboard content and masking real load errors.

Useful? React with 👍 / 👎.

@ratulsarna
Copy link
Collaborator

ratulsarna commented Feb 21, 2026

Opened a follow-up draft PR to carry this forward with the cancellation-completion fix: #413

Supersedes #409.

Thanks again @spirosrap for the original fix and the groundwork here.

@ratulsarna ratulsarna closed this Feb 21, 2026
@spirosrap spirosrap deleted the fix-openai-web-ignore-cancelled-navigation branch February 21, 2026 17:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error: The operation couldn’t be completed. (NSURLErrorDomain error -999.)

2 participants