Commit 8eed767
committed
fix: add buffered DMMF API to bypass V8 string length limit
Add get_dmmf_buffered(), read_dmmf_chunk(), and free_dmmf_buffer() to
prisma-schema-wasm. These allow the DMMF JSON to be returned as chunked
Uint8Array data instead of a single JS string, bypassing V8's hard limit
of ~536MB (0x1fffffe8 characters).
For schemas generating DMMF larger than ~536MB, the existing get_dmmf()
throws 'Cannot create a string longer than 0x1fffffe8 characters' because
wasm-bindgen converts the Rust String to a JS string. The new buffered API
keeps the JSON as bytes in WASM linear memory and lets JS read chunks as
Uint8Array (which has no such limit).
Changes:
- query-compiler/dmmf/src/lib.rs: add dmmf_json_bytes_from_validated_schema()
using serde_json::to_vec() instead of to_string()
- prisma-fmt/src/get_dmmf.rs: add get_dmmf_bytes() returning Vec<u8>
- prisma-fmt/src/lib.rs: export get_dmmf_bytes()
- prisma-schema-wasm/src/lib.rs: add 3 wasm_bindgen exports:
- get_dmmf_buffered(params) -> byte count
- read_dmmf_chunk(offset, length) -> Uint8Array
- free_dmmf_buffer()
Tested with a 1,600+ model schema producing 571MB DMMF:
- Original get_dmmf: FAILS (V8 string limit)
- Buffered API: PASSES (35 chunks x 16MB, streamed successfully)
Fixes: prisma/prisma#291111 parent aa5ee09 commit 8eed767
File tree
4 files changed
+76
-0
lines changed- prisma-fmt/src
- prisma-schema-wasm/src
- query-compiler/dmmf/src
4 files changed
+76
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
24 | 37 | | |
25 | 38 | | |
26 | 39 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
303 | 303 | | |
304 | 304 | | |
305 | 305 | | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
306 | 312 | | |
307 | 313 | | |
308 | 314 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
2 | 3 | | |
3 | 4 | | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
4 | 11 | | |
5 | 12 | | |
6 | 13 | | |
| |||
132 | 139 | | |
133 | 140 | | |
134 | 141 | | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
135 | 182 | | |
136 | 183 | | |
137 | 184 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
24 | 34 | | |
25 | 35 | | |
26 | 36 | | |
| |||
0 commit comments