Commit 1f0d677
committed
Prevent maxNewRequests from blocking on async producers
Exact `requestsOverLimit` reporting for async iterables currently requires
fully draining the producer after the budget is already exhausted. That
turns a bounded enqueue operation into a blocking one when the producer
stalls. This change keeps exact leftover reporting for materialized inputs
(and for callers that explicitly opt into waiting), while letting the
default async-iterable path return as soon as the budget is reached.
Constraint: Preserve exact leftover reporting for arrays and for callers that explicitly set waitForAllRequestsToBeAdded
Rejected: Remove requestsOverLimit entirely for every input type | too broad and breaks useful existing behavior for materialized sources
Confidence: medium
Scope-risk: moderate
Reversibility: clean
Directive: If the requestsOverLimit contract changes again, keep async-producer liveness and exact leftover reporting as separate concerns
Tested: `node node_modules/vitest/vitest.mjs run test/core/crawlers/basic_crawler.test.ts -t 'addRequestsBatched with maxNewRequests should not wait for an async iterable beyond the remaining budget'`; `node node_modules/vitest/vitest.mjs run test/core/crawlers/basic_crawler.test.ts -t 'addRequestsBatched with maxNewRequests should correctly report requestsOverLimit for generator input'`; `node node_modules/vitest/vitest.mjs run test/core/crawlers/basic_crawler.test.ts -t 'addRequestsBatched with maxNewRequests should correctly report requestsOverLimit for array input'`
Not-tested: Full test suite; behavior for custom iterable implementations beyond the covered array/async-generator cases1 parent 1d4f6b9 commit 1f0d677
2 files changed
Lines changed: 54 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
456 | 456 | | |
457 | 457 | | |
458 | 458 | | |
| 459 | + | |
| 460 | + | |
459 | 461 | | |
460 | 462 | | |
461 | 463 | | |
| |||
507 | 509 | | |
508 | 510 | | |
509 | 511 | | |
510 | | - | |
511 | | - | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
512 | 515 | | |
513 | 516 | | |
514 | 517 | | |
| |||
521 | 524 | | |
522 | 525 | | |
523 | 526 | | |
524 | | - | |
| 527 | + | |
525 | 528 | | |
526 | 529 | | |
527 | 530 | | |
| |||
561 | 564 | | |
562 | 565 | | |
563 | 566 | | |
564 | | - | |
565 | | - | |
| 567 | + | |
| 568 | + | |
566 | 569 | | |
567 | 570 | | |
568 | 571 | | |
| |||
1031 | 1034 | | |
1032 | 1035 | | |
1033 | 1036 | | |
1034 | | - | |
1035 | | - | |
| 1037 | + | |
| 1038 | + | |
| 1039 | + | |
| 1040 | + | |
1036 | 1041 | | |
1037 | 1042 | | |
1038 | 1043 | | |
| |||
1061 | 1066 | | |
1062 | 1067 | | |
1063 | 1068 | | |
| 1069 | + | |
| 1070 | + | |
| 1071 | + | |
| 1072 | + | |
1064 | 1073 | | |
1065 | 1074 | | |
1066 | 1075 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1947 | 1947 | | |
1948 | 1948 | | |
1949 | 1949 | | |
1950 | | - | |
| 1950 | + | |
| 1951 | + | |
| 1952 | + | |
| 1953 | + | |
1951 | 1954 | | |
1952 | 1955 | | |
1953 | 1956 | | |
| |||
1957 | 1960 | | |
1958 | 1961 | | |
1959 | 1962 | | |
| 1963 | + | |
| 1964 | + | |
| 1965 | + | |
| 1966 | + | |
| 1967 | + | |
| 1968 | + | |
| 1969 | + | |
| 1970 | + | |
| 1971 | + | |
| 1972 | + | |
| 1973 | + | |
| 1974 | + | |
| 1975 | + | |
| 1976 | + | |
| 1977 | + | |
| 1978 | + | |
| 1979 | + | |
| 1980 | + | |
| 1981 | + | |
| 1982 | + | |
| 1983 | + | |
| 1984 | + | |
| 1985 | + | |
| 1986 | + | |
| 1987 | + | |
| 1988 | + | |
| 1989 | + | |
| 1990 | + | |
| 1991 | + | |
| 1992 | + | |
| 1993 | + | |
| 1994 | + | |
| 1995 | + | |
| 1996 | + | |
1960 | 1997 | | |
1961 | 1998 | | |
1962 | 1999 | | |
| |||
0 commit comments