fs: make `FileHandle.readableWebStream` always create byte streams · nodejs/node@ccaf7fe
@@ -87,11 +87,11 @@ const check = readFileSync(__filename, { encoding: 'utf8' });
8787await file.close();
8888})().then(common.mustCall());
898990-// Make sure 'bytes' stream works
90+// Make sure 'byob' reader works
9191(async () => {
9292const file = await open(__filename);
9393const dec = new TextDecoder();
94-const readable = file.readableWebStream({ type: 'bytes' });
94+const readable = file.readableWebStream();
9595const reader = readable.getReader({ mode: 'byob' });
96969797let data = '';
@@ -114,59 +114,16 @@ const check = readFileSync(__filename, { encoding: 'utf8' });
114114await file.close();
115115})().then(common.mustCall());
116116117-// Make sure that acquiring a ReadableStream 'bytes' stream
118-// fails if the FileHandle is already closed.
119-(async () => {
120-const file = await open(__filename);
121-await file.close();
122-123-assert.throws(() => file.readableWebStream({ type: 'bytes' }), {
124-code: 'ERR_INVALID_STATE',
125-});
126-})().then(common.mustCall());
127-128-// Make sure that acquiring a ReadableStream 'bytes' stream
129-// fails if the FileHandle is already closing.
130-(async () => {
131-const file = await open(__filename);
132-file.close();
133-134-assert.throws(() => file.readableWebStream({ type: 'bytes' }), {
135-code: 'ERR_INVALID_STATE',
136-});
137-})().then(common.mustCall());
138-139-// Make sure the 'bytes' ReadableStream is closed when the underlying
140-// FileHandle is closed.
141-(async () => {
142-const file = await open(__filename);
143-const readable = file.readableWebStream({ type: 'bytes' });
144-const reader = readable.getReader({ mode: 'byob' });
145-file.close();
146-await reader.closed;
147-})().then(common.mustCall());
148-149-// Make sure the 'bytes' ReadableStream is closed when the underlying
150-// FileHandle is closed.
151-(async () => {
152-const file = await open(__filename);
153-const readable = file.readableWebStream({ type: 'bytes' });
154-file.close();
155-const reader = readable.getReader({ mode: 'byob' });
156-await reader.closed;
157-})().then(common.mustCall());
158-159-// Make sure that the FileHandle is properly marked "in use"
160-// when a 'bytes' ReadableStream has been acquired for it.
117+// Make sure a warning is logged if a non-'bytes' type is passed.
161118(async () => {
162119const file = await open(__filename);
163-file.readableWebStream({ type: 'bytes' });
164-const mc = new MessageChannel();
165-mc.port1.onmessage = common.mustNotCall();
166-assert.throws(() => mc.port2.postMessage(file, [file]), {
167-code: 25,
168-name: 'DataCloneError',
120+common.expectWarning({
121+ExperimentalWarning: [
122+'A non-"bytes" options.type has no effect. A byte-oriented steam is ' +
123+'always created.',
124+],
169125});
170-mc.port1.close();
126+const stream = file.readableWebStream({ type: 'foobar' });
127+await stream.cancel();
171128await file.close();
172129})().then(common.mustCall());