Repository navigation
Commit bd8f4e2
fix(deploy): read the framework Worker config as JSONC (#498)
Fixes #484
## Problem
```
void domain add → "// void:published-traffic:v1:..." saved in void.lock.json
fresh checkout → restored into .void-wrangler.jsonc (valid JSONC)
void deploy → prepareCfFrameworkBuildOutput: JSON.parse(...) ✗
Unexpected token '/', "// void:pu"... is not valid JSON
```
It affects framework apps whose Worker output is deployed directly
(Astro, SvelteKit, Nuxt, Analog).
## Fix
`prepareCfFrameworkBuildOutput` now reads the config with
`readGeneratedWranglerConfigFile`. Other code that reads this file
already uses that helper. It accepts comments, a BOM and trailing
commas, and still rejects bad input.
The issue also names two other `JSON.parse` reads in
`cf-build-output.ts`. I left them as they are on purpose, because Void
always writes those files as plain JSON:
| Read | File | Written by |
|---|---|---|
| `prepareCfStaticBuildOutput` |
`.void/deploy/cloudflare/wrangler-static.json` | `JSON.stringify`
(deploy-cloudflare-static.ts) |
| `prepareCfBuildOutput` | build output `wrangler.json` |
`@cloudflare/vite-plugin` or a scratch dir, both `JSON.stringify` |
## Tests
`packages/void/test/unit/cf-build-output.test.ts`:
- **Real flow:** write the snapshot with Void's own writer, delete the
config, restore it from the lock, run
`writeCloudflareFrameworkDeployConfig`, follow the deploy pointer, then
prepare the build output.
- **Parsing:** JSONC with a BOM, a comment and a trailing comma is
accepted. A broken config or a non-object config is still rejected.
On `main`, both tests fail with the error from the issue. Checks run:
- 5 deploy-path unit files pass (645 tests);
- lint, format and typecheck are clean.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>1 parent 293ea34 commit bd8f4e2
2 files changed
Lines changed: 107 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| 31 | + | |
31 | 32 | | |
32 | 33 | | |
33 | 34 | | |
| |||
388 | 389 | | |
389 | 390 | | |
390 | 391 | | |
391 | | - | |
392 | | - | |
393 | | - | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
394 | 397 | | |
395 | 398 | | |
396 | 399 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
28 | 31 | | |
29 | 32 | | |
30 | 33 | | |
| |||
33 | 36 | | |
34 | 37 | | |
35 | 38 | | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
36 | 43 | | |
37 | 44 | | |
38 | 45 | | |
| |||
828 | 835 | | |
829 | 836 | | |
830 | 837 | | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
| 841 | + | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
| 857 | + | |
| 858 | + | |
| 859 | + | |
| 860 | + | |
| 861 | + | |
| 862 | + | |
| 863 | + | |
| 864 | + | |
| 865 | + | |
| 866 | + | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
| 878 | + | |
| 879 | + | |
| 880 | + | |
| 881 | + | |
| 882 | + | |
| 883 | + | |
| 884 | + | |
| 885 | + | |
| 886 | + | |
| 887 | + | |
| 888 | + | |
| 889 | + | |
| 890 | + | |
| 891 | + | |
| 892 | + | |
| 893 | + | |
| 894 | + | |
| 895 | + | |
| 896 | + | |
| 897 | + | |
| 898 | + | |
| 899 | + | |
| 900 | + | |
| 901 | + | |
| 902 | + | |
| 903 | + | |
| 904 | + | |
| 905 | + | |
| 906 | + | |
| 907 | + | |
| 908 | + | |
| 909 | + | |
| 910 | + | |
| 911 | + | |
| 912 | + | |
| 913 | + | |
| 914 | + | |
| 915 | + | |
| 916 | + | |
| 917 | + | |
| 918 | + | |
| 919 | + | |
| 920 | + | |
| 921 | + | |
| 922 | + | |
| 923 | + | |
| 924 | + | |
| 925 | + | |
| 926 | + | |
| 927 | + | |
| 928 | + | |
| 929 | + | |
| 930 | + | |
831 | 931 | | |
832 | 932 | | |
833 | 933 | | |
| |||
0 commit comments