Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Include submitter data in partial form data #2307

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

adamgreg
Copy link
Contributor

Fixes #2306

Copy link
Collaborator

@marvinhagemeister marvinhagemeister left a comment

Choose a reason for hiding this comment

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

Awesome, this is great! Thanks for opening a PR 👍 Let's add a test case and then it's ready to be merged

@adamgreg
Copy link
Contributor Author

Awesome, this is great! Thanks for opening a PR 👍 Let's add a test case and then it's ready to be merged

Hi @marvinhagemeister I've tried adding a simple test case, but it's failing and I don't understand why. I've tried the fixture pages in my browser, and they behave as I would expect, but the assertion in the test itself fails. I have a feeling the problem will be obvious to you, so please could you take a look?

@adamgreg
Copy link
Contributor Author

TLDR: The feature works fine, but unit tests require a newer version of Puppeteer, which is not easily available.

Fresh uses a Deno fork of Puppeteer version 16.2.0 from deno.land/x . That installs and runs an old version of Headless Chrome: HeadlessChrome/105.0.5173.0 (mid-2022). Support for adding submitter data to formData was not added until Chrome v112: https://chromestatus.com/feature/5066604734316544. Unfortunately, 16.2.0 is the latest version available of Luca's Deno fork.

The good news is that it's now possible to run the latest version of Puppeteer directly from npm:puppeteer... The bad news about that is that it leaks ops and resources: puppeteer/puppeteer#11839 . Tests will only pass if the sanitizers are disabled. I've tried monkey-patching NodeWebSocketTransport as suggested in that issue - it dealt with the leaked ops, but not some leaked timer resources.

An update to deno-puppeteer would solve the problem, but it seems unlikely judging by lucacasonato/deno-puppeteer#64.

@adamgreg
Copy link
Contributor Author

adamgreg commented Feb 14, 2024

@marvinhagemeister as a quick fix I could add the submitter name&value manually to the formData instead of depending on the constructor to do it?

EDIT: I've added a commit to do that, which should make the unit tests pass.

This is needed to support older browsers, including that used by Puppeteer v16.2.0 for Fresh's unit tests
@adamgreg
Copy link
Contributor Author

Hi @marvinhagemeister is this OK? I'm not a fan of adding the form data manually, but it has the same effect and seems to be the only way to make it testable with this version of Puppeteer.

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.

Partial form submission omits submitter from formData
2 participants