@@ -4,40 +4,7 @@ import parserWebStream, {parser as parserFromWeb} from '../../src/web/index.js';
44import parserWebFactory , { parser as parserFromWebSubpath } from '../../src/web/parser.js' ;
55import coreParser from '../../src/core/parser.js' ;
66
7- // Feature probe: `stream-chain`'s `asWebStream` (src/asWebStream.js) relies on
8- // `WritableStreamDefaultController.signal` (WHATWG Streams §4.5.2) to wake
9- // blocked writes on abort. Node and Deno expose it; Bun (≤1.3.14) does not.
10- // Trackers: Bun-side at https://github.com/oven-sh/bun/issues/31156, fix /
11- // fallback consideration on the `stream-chain` side at
12- // https://github.com/uhop/stream-chain (the dependency on the spec attribute
13- // lives there, not here — stream-json's wrapper just calls into
14- // `parser.asWebStream`). Skip the runtime test on runtimes that lack the
15- // signal so the suite still passes there; the unit tests below (which only
16- // inspect the attached factory shape) still run.
17- let hasWritableControllerSignal = false ;
18- try {
19- await new Promise ( resolve => {
20- new WritableStream ( {
21- start ( controller ) {
22- hasWritableControllerSignal = controller . signal instanceof AbortSignal ;
23- resolve ( ) ;
24- } ,
25- write ( ) { }
26- } )
27- . getWriter ( )
28- . write ( 'x' )
29- . catch ( ( ) => { } ) ;
30- } ) ;
31- } catch {
32- // ignore probe errors
33- }
34-
357test . asPromise ( 'web: parserWebStream produces Web TransformStream pair' , async ( t , resolve , reject ) => {
36- if ( ! hasWritableControllerSignal ) {
37- t . comment ( 'skipped: runtime lacks WritableStreamDefaultController.signal (e.g. Bun ≤1.3.14)' ) ;
38- resolve ( ) ;
39- return ;
40- }
418 try {
429 const pair = parserWebStream ( ) ;
4310 t . ok ( pair . readable instanceof ReadableStream , 'has ReadableStream' ) ;
0 commit comments