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

🐛 BUG: vitest-pool-workers: Pages project with pages_build_output_dir in wrangler.toml fails #5768

Open
osaton opened this issue May 6, 2024 · 1 comment
Labels
bug Something that isn't working

Comments

@osaton
Copy link

osaton commented May 6, 2024

Which Cloudflare product(s) does this pertain to?

Wrangler core

What version(s) of the tool(s) are you using?

3.35.1

What version of Node are you using?

20.11.0

What operating system and version are you using?

Mac Sonoma 14.4

Describe the Bug

Observed behavior

Test process exits with error "Pages doesn't currently support JSON formatted config /my-project/wrangler.toml. Please use wrangler.toml instead." when run in a pages project with wrangler.toml containing pages_build_output_dir

Expected behavior

Should run tests normally

Please provide a link to a minimal reproduction

https://github.com/osaton/temp-black-waterfall-44dc

Please provide any relevant error logs

❯  readConfig node_modules/wrangler/wrangler-dist/cli.js:158419:11
❯ Module.unstable_getMiniflareWorkerOptions node_modules/wrangler/wrangler-dist/cli.js:206586:18
❯ parseCustomPoolOptions node_modules/@cloudflare/vitest-pool-workers/dist/pool/index.mjs:212:54
❯ parseProjectOptions node_modules/@cloudflare/vitest-pool-workers/dist/pool/index.mjs:253:12
❯ Object.runTests node_modules/@cloudflare/vitest-pool-workers/dist/pool/index.mjs:1410:22

First unstable_getMiniflareWorkerOptions passes experimentalJsonConfig: true to readConfig which throws at packages/wrangler/src/config/index.ts:100 because of experimantalJsonConfig check:

if (
	isPagesConfigFile &&
	(configPath?.endsWith("json") || args.experimentalJsonConfig)
) {
	throw new UserError(
		`Pages doesn't currently support JSON formatted config \`${
			configPath ?? "wrangler.json"
		}\`. Please use wrangler.toml instead.`
	);
}

Which makes me think if the || args.experimentalJsonConfig part is even needed here? we have already parsed the config based on the file extension, so we know that the config is not in JSON format, so maybe isPagesConfigFile && configPath?.endsWith("json") would be sufficient here?

@osaton osaton added the bug Something that isn't working label May 6, 2024
@ericmatthys
Copy link

I came across this bug trying to get the Vitest integration working with Pages Functions and Wasm. Patching the experimentalJsonConfig option to false when unstable_getMiniflareWorkerOptions is called was enough to unblock me for now, but that is just a temporary hack of course.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something that isn't working
Projects
Status: Untriaged
Development

No branches or pull requests

2 participants