Commit a23b5ff
fix(core): [PER-9706] sync Automate snapshots fail with "upload is not async iterable" (#2314)
* fix(core): stop async-iterating percy.upload() in sync relay routes
percy.upload() is the generatePromise-wrapped method and returns a Promise,
not an async iterable. The sync branches of /percy/comparison,
/percy/maestro-screenshot and /percy/automateScreenshot were changed (while
fixing Maestro sync) to `for await (const _ of percy.upload(...))`, which
throws "upload is not async iterable". SDKs surface this as
{"error":"upload is not async iterable"} on every sync snapshot, regressing
Percy-on-Automate sync (sync: true) on @percy/cli 1.32.0-1.32.2.
generatePromise already drives the underlying async generator to completion,
so calling percy.upload() inside the Promise executor enqueues #snapshots and
lets the sync queue resolve/reject the attached callback. Revert all three
sync routes to that proven 1.31.8 pattern (the raw generator remains
available at percy.yield.upload() if direct iteration is ever needed).
The original drain-canary tests passed only because they mocked percy.upload
to return an async generator, contradicting its real shape. Replace them with
regression tests that model the real return shape (a Promise that resolves
the callback asynchronously), so async-iterating the return value would fail.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* fix(core): guard sync upload against generator errors and strengthen tests
Address PR review on the sync relay fix:
- Add a trailing .catch(reject) to percy.upload() at all three sync routes
(/percy/comparison, /percy/maestro-screenshot, /percy/automateScreenshot)
so a generator error that bypasses the sync-queue callback (e.g. a throw
before the queue task runs) is surfaced as data.error via handleSyncJob
instead of leaking an unhandled rejection and hanging the request.
- Assert percy.client.getComparisonDetails was called in the three sync
regression tests, proving handleSyncJob ran to completion rather than the
request resolving early.
- Add a /percy/comparison test that a rejected upload Promise (no callback
invoked) surfaces as data.error, directly covering the new .catch(reject).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent c1e8904 commit a23b5ff
2 files changed
Lines changed: 73 additions & 62 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
385 | 385 | | |
386 | 386 | | |
387 | 387 | | |
388 | | - | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
389 | 396 | | |
390 | | - | |
391 | | - | |
392 | | - | |
393 | | - | |
394 | | - | |
| 397 | + | |
395 | 398 | | |
396 | 399 | | |
397 | 400 | | |
| |||
905 | 908 | | |
906 | 909 | | |
907 | 910 | | |
908 | | - | |
909 | | - | |
| 911 | + | |
| 912 | + | |
| 913 | + | |
910 | 914 | | |
911 | | - | |
912 | | - | |
913 | | - | |
914 | | - | |
915 | | - | |
| 915 | + | |
916 | 916 | | |
917 | 917 | | |
918 | 918 | | |
| |||
946 | 946 | | |
947 | 947 | | |
948 | 948 | | |
949 | | - | |
| 949 | + | |
| 950 | + | |
| 951 | + | |
950 | 952 | | |
951 | | - | |
952 | | - | |
953 | | - | |
954 | | - | |
955 | | - | |
| 953 | + | |
956 | 954 | | |
957 | 955 | | |
958 | 956 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
336 | 336 | | |
337 | 337 | | |
338 | 338 | | |
339 | | - | |
340 | | - | |
341 | | - | |
342 | | - | |
343 | | - | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
344 | 345 | | |
345 | 346 | | |
346 | | - | |
347 | | - | |
348 | | - | |
349 | | - | |
350 | | - | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
351 | 350 | | |
352 | 351 | | |
353 | 352 | | |
354 | 353 | | |
355 | 354 | | |
356 | 355 | | |
357 | | - | |
| 356 | + | |
358 | 357 | | |
359 | 358 | | |
360 | 359 | | |
361 | 360 | | |
362 | 361 | | |
363 | | - | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
364 | 383 | | |
365 | 384 | | |
366 | 385 | | |
| |||
607 | 626 | | |
608 | 627 | | |
609 | 628 | | |
610 | | - | |
611 | | - | |
612 | | - | |
613 | | - | |
614 | | - | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
615 | 633 | | |
616 | 634 | | |
617 | 635 | | |
618 | | - | |
619 | | - | |
620 | | - | |
621 | | - | |
622 | | - | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
623 | 639 | | |
624 | 640 | | |
625 | 641 | | |
626 | 642 | | |
627 | 643 | | |
628 | 644 | | |
629 | | - | |
| 645 | + | |
630 | 646 | | |
631 | 647 | | |
632 | 648 | | |
633 | 649 | | |
634 | 650 | | |
635 | 651 | | |
636 | | - | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
637 | 655 | | |
638 | 656 | | |
639 | 657 | | |
| |||
1568 | 1586 | | |
1569 | 1587 | | |
1570 | 1588 | | |
1571 | | - | |
1572 | | - | |
1573 | | - | |
1574 | | - | |
1575 | | - | |
| 1589 | + | |
| 1590 | + | |
| 1591 | + | |
1576 | 1592 | | |
1577 | 1593 | | |
1578 | 1594 | | |
| |||
1587 | 1603 | | |
1588 | 1604 | | |
1589 | 1605 | | |
1590 | | - | |
1591 | | - | |
1592 | | - | |
1593 | | - | |
1594 | | - | |
| 1606 | + | |
| 1607 | + | |
| 1608 | + | |
| 1609 | + | |
1595 | 1610 | | |
1596 | 1611 | | |
1597 | | - | |
1598 | | - | |
1599 | | - | |
1600 | | - | |
1601 | | - | |
1602 | | - | |
| 1612 | + | |
| 1613 | + | |
| 1614 | + | |
1603 | 1615 | | |
1604 | 1616 | | |
1605 | 1617 | | |
| |||
1610 | 1622 | | |
1611 | 1623 | | |
1612 | 1624 | | |
1613 | | - | |
1614 | | - | |
1615 | | - | |
| 1625 | + | |
| 1626 | + | |
| 1627 | + | |
| 1628 | + | |
1616 | 1629 | | |
1617 | 1630 | | |
1618 | 1631 | | |
| |||
0 commit comments