Skip to content

chore: sync upstream PR #8546 - fix(ios) Canceling a WKURLSchemeTask cancels the associated URLSessionTask - #119

Open
riderx wants to merge 1 commit into
plusfrom
sync/upstream-pr-8546
Open

chore: sync upstream PR #8546 - fix(ios) Canceling a WKURLSchemeTask cancels the associated URLSessionTask#119
riderx wants to merge 1 commit into
plusfrom
sync/upstream-pr-8546

Conversation

@riderx

@riderx riderx commented Aug 25, 2026

Copy link
Copy Markdown
Member

Merge Conflict Review Required

The sync of upstream PR ionic-team#8546 from @lazerwalker encountered merge conflicts.

Original PR: ionic-team#8546

What happened

  • Git applied the upstream-preferred merge strategy
  • This PR requires CI and manual review before merging

Synced from upstream by Capacitor+ Bot


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

Review in cubic

@riderx

riderx commented Aug 25, 2026

Copy link
Copy Markdown
Member Author

Git applied the upstream-preferred strategy to resolve this sync. Please review the branch carefully before merging.

@github-actions

Copy link
Copy Markdown

Beta npm build

Maintainers can publish one Capacitor Plus workspace package from this PR to npm for fast testing.

Comment /publish-beta <package> after the PR checks are green.

Examples:

/publish-beta core
/publish-beta cli
/publish-beta @capacitor-plus/core

If exactly one workspace package changed, /publish-beta without a package will use that package.

Packages:

  • core (@capacitor-plus/core)
  • cli (@capacitor-plus/cli)
  • android (@capacitor-plus/android)
  • ios (@capacitor-plus/ios)

The workflow will:

  • publish a prerelease package on the beta tag
  • update this comment with the install command

Security note: beta publish is only enabled for branches inside this repository.

@coderabbitai

coderabbitai Bot commented Aug 25, 2026

Copy link
Copy Markdown

Warning

Review limit reached

  • Run on-demand review

On-demand reviews are free for the next 24 days. After that, they cost $0.25 per reviewed file.

Or wait 8 minutes for your next included review.

View limit details

Limit details: You’ve used all 2 included reviews currently available. Your 55 included PR review attempts over the past 7 days set your current allowance at 2 reviews per hour.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: c79d6cdb-5824-412e-b90c-32e4bac56992

📥 Commits

Reviewing files that changed from the base of the PR and between 8687b31 and 3e5ff17.

📒 Files selected for processing (3)
  • ios/Capacitor/Capacitor.xcodeproj/project.pbxproj
  • ios/Capacitor/Capacitor/WebViewAssetHandler.swift
  • ios/Capacitor/CapacitorTests/WebViewAssetHandlerTests.swift

Comment @coderabbitai help to get the list of available commands.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

All reported issues were addressed across 36 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread cli/package.json Outdated
Comment thread android/package.json Outdated
Comment thread android/capacitor/src/main/java/com/getcapacitor/plugin/SystemBars.java Outdated
Comment thread android/capacitor/src/main/java/com/getcapacitor/plugin/SystemBars.java Outdated
Comment thread cli/src/tasks/migrate-uiscene.ts Outdated
Comment thread cli/src/tasks/migrate.ts Outdated
Comment thread CHANGELOG.md
Comment thread android/package.json
Comment thread cli/test/migrate-uiscene-scan.spec.ts Outdated
@cursor
cursor Bot force-pushed the sync/upstream-pr-8546 branch from e9d5a4b to c6a9a35 Compare August 26, 2026 15:55
@riderx
riderx force-pushed the sync/upstream-pr-8546 branch from c6a9a35 to c1e6786 Compare August 27, 2026 08:59
@riderx

riderx commented Aug 27, 2026

Copy link
Copy Markdown
Member Author

Git applied the upstream-preferred strategy to resolve this sync. Please review the branch carefully before merging.

Right now, when WebKit cancels a request (due to navigating to a new page,
client JS manually cancelling a fetch via AbortController, etc) it calls the
handler's webView(_:stop:). Today that only sets a "stopped" flag on the
WKURLSchemeTask (an associated bool added via an extension) but doesn't
actually stop the underlying network request.

In other words: cancelling a network request using native browser semantics does
not actually cancel said network request.

In my own app this causes a production issue. We cancel requests with a manual
timeout, but since the underlying `URLSession` task is never cancelled, each
timed-out request keeps running and holds one of `URLSession.shared`'s limited
per-host connections until its own, much longer, timeout fires. These orphaned
requests pile up faster than they clear, exhaust the connection pool, and new
requests queue behind them.

This PR now stores the URLSession task alongside the WKURLSchemeTask
(as an associated object in an extension, like `stopped`), so that when
`stop()` is called, we can cancel the request.

There's a test as well, that fails prior to this patch and passes with it.
It just shows that, previously, calling stop() from the web view did not in fact
stop the underlying network request, while now it does.

Note that this change only affects iOS; I am unclear if the Android implementation
has similar issues, but that's out of scope for this PR.

Additionally calling out that adding an internal `urlSession` property instead
of hardcoding `URLSession.shared` is a change that technically only exists for
testing, but as an internal-only change I don't think it's egregious here. If
you wanted to merge this change without merging the test, I'd remove that as well.
@cursor
cursor Bot force-pushed the sync/upstream-pr-8546 branch from c1e6786 to 3e5ff17 Compare August 27, 2026 09:02
@TorichanCapgo

Copy link
Copy Markdown

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 27, 2026

Copy link
Copy Markdown
⚠️ Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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.

3 participants