Skip to content

Split WASM PAL into focused files - #54

Merged
snelusha merged 3 commits into
mainfrom
refactor/wasm-pal
Aug 11, 2026
Merged

Split WASM PAL into focused files#54
snelusha merged 3 commits into
mainfrom
refactor/wasm-pal

Conversation

@snelusha

@snelusha snelusha commented Aug 7, 2026

Copy link
Copy Markdown
Owner

Resolved #51

Summary by CodeRabbit

  • New Features
    • Added browser-based HTTP support for WebAssembly applications, including headers, request bodies, redirects, cancellation, timeouts, streamed responses, and response-size limits.
    • Added WebAssembly filesystem support for reading, writing, appending, and creating required directories.
  • Bug Fixes
    • Improved handling and propagation of HTTP, response-reading, and filesystem errors.
    • Added validation for required browser capabilities and directory paths.
    • Oversized responses are now cancelled automatically.

@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@snelusha, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 27 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: c2fcb37e-11be-4ea0-b715-9b5a3406b9a7

📥 Commits

Reviewing files that changed from the base of the PR and between 5973217 and d3f0b33.

📒 Files selected for processing (6)
  • packages/ballerina-wasm/http_client_wasm.go
  • packages/ballerina-wasm/pal_fs_wasm.go
  • packages/balrun/src/fs/core.ts
  • packages/balrun/src/fs/node.ts
  • packages/balrun/src/wasm-bridge.ts
  • packages/balrun/tests/wasm-bridge.test.ts
📝 Walkthrough

Walkthrough

The WASM PAL implementation now stores its HTTP client and filesystem wrapper in separate files. The HTTP client uses Fetch and AbortController. The filesystem wrapper provides synchronized bridged file operations. pal_wasm.go retains PAL wiring.

Changes

WASM PAL refactor

Layer / File(s) Summary
Fetch HTTP client
packages/ballerina-wasm/http_client_wasm.go
Adds fetchHTTPClient.Execute with request bodies, headers, redirects, cancellation, timeouts, response headers, streamed response bodies, and response-size limits.
Bridged filesystem operations
packages/ballerina-wasm/pal_fs_wasm.go
Adds palFS with path resolution, parent-directory creation, synchronized reads, writes, and appends.
PAL implementation wiring
packages/ballerina-wasm/pal_wasm.go
Removes the local HTTP and filesystem implementations while retaining PAL wiring to fetchHTTPClient and palFS.

Estimated code review effort: 4 (Complex) | ~45 minutes

Possibly related PRs

  • snelusha/balrun#50: Moves the WASM HTTP client and filesystem implementations into dedicated files.
  • snelusha/balrun#18: Also modifies the WASM PAL HTTP implementation and fetchHTTPClient wiring.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the primary change: splitting the WASM PAL implementation into focused files.
Linked Issues check ✅ Passed The changes refactor the WASM PAL implementation into separate HTTP client and filesystem files, satisfying issue #51.
Out of Scope Changes check ✅ Passed The changes remain within the refactoring scope of issue #51 and show no unrelated code changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/wasm-pal

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@snelusha
snelusha force-pushed the refactor/wasm-pal branch from 8394d70 to f6801be Compare August 7, 2026 21:57
Base automatically changed from feat/os to main August 7, 2026 22:00
@snelusha
snelusha force-pushed the refactor/wasm-pal branch from f6801be to bef7ac0 Compare August 7, 2026 22:00
@snelusha

snelusha commented Aug 8, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Aug 8, 2026

Copy link
Copy Markdown
✅ Action performed

Full review finished.

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/ballerina-wasm/http_client_wasm.go`:
- Around line 207-219: Update extractBody to avoid Response.arrayBuffer() and
consume Response.body incrementally through a reader, tracking accumulated bytes
and stopping immediately with the configured size error when limit is exceeded.
Preserve the existing response-body error handling and return the collected
bytes only after the full stream is read within the limit.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 36714d62-ddb0-4abb-bb16-4cae3aa142dd

📥 Commits

Reviewing files that changed from the base of the PR and between 077b448 and bef7ac0.

📒 Files selected for processing (3)
  • packages/ballerina-wasm/http_client_wasm.go
  • packages/ballerina-wasm/pal_fs_wasm.go
  • packages/ballerina-wasm/pal_wasm.go
💤 Files with no reviewable changes (1)
  • packages/ballerina-wasm/pal_wasm.go

Comment thread packages/ballerina-wasm/http_client_wasm.go Outdated
@snelusha
snelusha force-pushed the refactor/wasm-pal branch from bef7ac0 to 3e789ec Compare August 9, 2026 17:42
@snelusha

snelusha commented Aug 9, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Aug 9, 2026

Copy link
Copy Markdown
✅ Action performed

Full review finished.

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/ballerina-wasm/http_client_wasm.go`:
- Around line 201-202: Update the response-size limit handling in the HTTP
client flow to cancel the response body’s ReadableStream before returning the
configured size-limit error, including both affected return paths. Preserve the
size-limit error regardless of whether stream cancellation succeeds, and ensure
cancellation is performed through the existing body reader before returning.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 17d34874-74e5-434b-8fec-78ce1c2e672f

📥 Commits

Reviewing files that changed from the base of the PR and between 50870e2 and 0de55ac.

📒 Files selected for processing (3)
  • packages/ballerina-wasm/http_client_wasm.go
  • packages/ballerina-wasm/pal_fs_wasm.go
  • packages/ballerina-wasm/pal_wasm.go
💤 Files with no reviewable changes (1)
  • packages/ballerina-wasm/pal_wasm.go

Comment thread packages/ballerina-wasm/http_client_wasm.go
@snelusha
snelusha force-pushed the refactor/wasm-pal branch from 0de55ac to 5f0f428 Compare August 9, 2026 21:54
@snelusha

Copy link
Copy Markdown
Owner Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown
✅ Action performed

Full review finished.

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/ballerina-wasm/http_client_wasm.go`:
- Around line 120-132: Update buildHeaders to return (js.Value, error),
capturing errors from each Headers.set/append call—including the Content-Type
assignment—instead of allowing js.Value.Call panics to escape. Propagate the
returned error through buildFetchOptions and its caller Execute, preserving
successful header construction while returning failures for invalid header names
or values.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: e515c4ce-f251-4421-b653-0fec3bf36176

📥 Commits

Reviewing files that changed from the base of the PR and between 50870e2 and 5f0f428.

📒 Files selected for processing (3)
  • packages/ballerina-wasm/http_client_wasm.go
  • packages/ballerina-wasm/pal_fs_wasm.go
  • packages/ballerina-wasm/pal_wasm.go
💤 Files with no reviewable changes (1)
  • packages/ballerina-wasm/pal_wasm.go

Comment thread packages/ballerina-wasm/http_client_wasm.go
@snelusha

Copy link
Copy Markdown
Owner Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown
✅ Action performed

Full review finished.

@coderabbitai coderabbitai 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.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/ballerina-wasm/http_client_wasm.go`:
- Around line 115-120: Update fetchHTTPClient.getRedirectMode so disabling
FollowRedirects preserves raw 3xx status and headers, especially Location,
instead of using Fetch’s opaque "manual" mode; use a metadata-preserving
strategy or explicitly reject this configuration on WASM.

In `@packages/ballerina-wasm/pal_fs_wasm.go`:
- Around line 25-28: Update the existing-file branch in the directory creation
logic around fs.Stat to return a *fs.PathError using syscall.ENOTDIR, or the
equivalent bridge-defined not-directory error, instead of fs.ErrInvalid.
Preserve the current path and operation values while retaining the existing
behavior for directories and stat errors.
- Around line 16-20: Update the path contract around palFS.resolvePath and
bridgeFS so absolute run paths are either rejected before reaching the proxy or
the proxy/FS contract explicitly normalizes and supports absolute paths. Ensure
relative-name implementations such as MemFS receive relative paths, while
preserving compatible behavior for NodeFS.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 818f1379-07ea-46b0-a980-8da958b53116

📥 Commits

Reviewing files that changed from the base of the PR and between 50870e2 and 5973217.

📒 Files selected for processing (3)
  • packages/ballerina-wasm/http_client_wasm.go
  • packages/ballerina-wasm/pal_fs_wasm.go
  • packages/ballerina-wasm/pal_wasm.go
💤 Files with no reviewable changes (1)
  • packages/ballerina-wasm/pal_wasm.go

Comment thread packages/ballerina-wasm/http_client_wasm.go Outdated
Comment thread packages/ballerina-wasm/pal_fs_wasm.go
Comment thread packages/ballerina-wasm/pal_fs_wasm.go Outdated
@snelusha
snelusha merged commit 498b74f into main Aug 11, 2026
2 checks passed
@snelusha
snelusha deleted the refactor/wasm-pal branch August 11, 2026 20:36
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.

Refactor WASM PAL implementation into separate files

1 participant