Sitelet https://github.com/flutter/flutter/pull/190584
Skip to content

[web] Provide Content-Length header for main.dart.wasm in flutter test - #190584

Merged
auto-submit[bot] merged 2 commits into
flutter:masterfrom
harryterkelsen:fix-skwasm-content-length
Aug 7, 2026
Merged

auto-submit[bot] merged 2 commits into
flutter:masterfrom
harryterkelsen:fix-skwasm-content-length

Conversation

@harryterkelsen

Copy link
Copy Markdown
Contributor

This adds the Content-Length header for main.dart.wasm when it's served in the shelf test server. This complements PR #190155 which fixed this for canvaskit.wasm. By providing the Content-Length header, shelf avoids falling back to Transfer-Encoding: chunked, which prevents a bug in Chrome 145's WebAssembly compilation from hanging Skwasm tests.

Fixes #189275

Pre-launch Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

If this change needs to override an active code freeze, provide a comment explaining why. The code freeze workflow can be overridden by code reviewers. See pinned issues for any active code freezes with guidance.

Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the gemini-code-assist bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.

@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label Aug 4, 2026
@flutter-dashboard

Copy link
Copy Markdown

It looks like this pull request may not have tests. Please make sure to add tests or get an explicit test exemption before merging.

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. If you believe this PR qualifies for a test exemption, contact "@test-exemption-reviewer" in the #hackers channel in Discord (don't just cc them here, they won't see it!). The test exemption team is a small volunteer group, so all reviewers should feel empowered to ask for tests, without delegating that responsibility entirely to the test exemption group.

@github-actions github-actions Bot added the tool Affects the "flutter" command-line tool. See also t: labels. label Aug 4, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request updates the WASM request handler in flutter_web_platform.dart to include the Content-Length header. The review feedback suggests verifying the existence of the WASM file before calling lengthSync() to prevent potential runtime exceptions, and recommends using string literals instead of HttpHeaders constants to maintain consistency with the surrounding code.

Comment thread packages/flutter_tools/lib/src/test/flutter_web_platform.dart
@eyebrowsoffire

Copy link
Copy Markdown
Contributor

I think we also might need to do this for the web benchmark harness as well.

@harryterkelsen

Copy link
Copy Markdown
Contributor Author

I think we also might need to do this for the web benchmark harness as well.

According to Gemini, the web benchmarks harness doesn't need this because it uses package:shelf_static:

The test server in flutter test was vulnerable because it was manually serving .wasm files by returning shelf.Response.ok(wasmFile.openRead()) without specifying the content length.

However, the web_benchmarks server relies on package:shelf_static to serve its built assets:

    cascade = cascade.add(createStaticHandler(
      path.join(benchmarkAppDirectory.path, 'build', 'web'),
      defaultDocument: 'index.html',
    ));

Under the hood, createStaticHandler automatically checks the file stats and includes the Content-Length header for all static files, including .wasm files. So we don't need to make any changes there!

@mdebbar mdebbar added the autosubmit Merge PR when tree becomes green via auto submit App label Aug 6, 2026
@auto-submit
auto-submit Bot added this pull request to the merge queue Aug 6, 2026
Merged via the queue into flutter:master with commit 8732c18 Aug 7, 2026
22 checks passed
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Aug 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CICD Run CI/CD tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

web_canvaskit_tests postsubmits recently became very flaky due to timeouts

3 participants