Commit 91fab9c
fix(server-hmr): re-require metadata route handlers per-request in Turbopack dev
Dynamic metadata routes (manifest, robots, sitemap, images) are generated as
virtual wrapper modules with a static top-level import of the user's handler.
When server HMR patches devModuleCache in-place for the user's file, the
wrapper's captured binding still references the old function.
Fix by adding a conditional require() inside the GET handler when running
under Turbopack dev server, mirroring the pattern already used for app-route
handlers. In production and webpack builds the branch is dead code and is
eliminated.
Fixes #91981
Co-Authored-By: Claude <noreply@anthropic.com>1 parent d84e3bb commit 91fab9c
File tree
4 files changed
+77
-17
lines changed- crates/next-core/src/next_app/metadata
- packages/next/src/build/swc
- test/development/app-dir/server-hmr
- app
4 files changed
+77
-17
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
237 | 237 | | |
238 | 238 | | |
239 | 239 | | |
240 | | - | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
241 | 248 | | |
242 | 249 | | |
243 | 250 | | |
| |||
293 | 300 | | |
294 | 301 | | |
295 | 302 | | |
296 | | - | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
297 | 311 | | |
298 | 312 | | |
299 | 313 | | |
| |||
314 | 328 | | |
315 | 329 | | |
316 | 330 | | |
317 | | - | |
| 331 | + | |
318 | 332 | | |
319 | 333 | | |
320 | 334 | | |
| |||
378 | 392 | | |
379 | 393 | | |
380 | 394 | | |
381 | | - | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
382 | 401 | | |
383 | 402 | | |
384 | 403 | | |
| |||
443 | 462 | | |
444 | 463 | | |
445 | 464 | | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
446 | 472 | | |
447 | 473 | | |
448 | | - | |
| 474 | + | |
449 | 475 | | |
450 | 476 | | |
451 | 477 | | |
| |||
460 | 486 | | |
461 | 487 | | |
462 | 488 | | |
463 | | - | |
| 489 | + | |
464 | 490 | | |
465 | 491 | | |
466 | 492 | | |
| |||
507 | 533 | | |
508 | 534 | | |
509 | 535 | | |
510 | | - | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
511 | 542 | | |
512 | 543 | | |
513 | 544 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
153 | 153 | | |
154 | 154 | | |
155 | 155 | | |
156 | | - | |
157 | | - | |
| 156 | + | |
| 157 | + | |
158 | 158 | | |
159 | 159 | | |
160 | 160 | | |
| |||
363 | 363 | | |
364 | 364 | | |
365 | 365 | | |
366 | | - | |
| 366 | + | |
367 | 367 | | |
368 | 368 | | |
369 | 369 | | |
| |||
522 | 522 | | |
523 | 523 | | |
524 | 524 | | |
525 | | - | |
| 525 | + | |
526 | 526 | | |
527 | 527 | | |
528 | 528 | | |
529 | 529 | | |
530 | 530 | | |
531 | | - | |
| 531 | + | |
532 | 532 | | |
533 | 533 | | |
534 | 534 | | |
| |||
537 | 537 | | |
538 | 538 | | |
539 | 539 | | |
540 | | - | |
| 540 | + | |
541 | 541 | | |
542 | 542 | | |
543 | 543 | | |
| |||
551 | 551 | | |
552 | 552 | | |
553 | 553 | | |
554 | | - | |
555 | | - | |
| 554 | + | |
| 555 | + | |
556 | 556 | | |
557 | 557 | | |
558 | 558 | | |
559 | 559 | | |
560 | 560 | | |
561 | 561 | | |
562 | | - | |
563 | | - | |
| 562 | + | |
| 563 | + | |
564 | 564 | | |
565 | 565 | | |
566 | 566 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
206 | 206 | | |
207 | 207 | | |
208 | 208 | | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
209 | 229 | | |
0 commit comments