-
Notifications
You must be signed in to change notification settings - Fork 23.1k
Closed
Labels
Content:WebAPIWeb API docsWeb API docsneeds triageTriage needed by staff and/or partners. Automatically applied when an issue is opened.Triage needed by staff and/or partners. Automatically applied when an issue is opened.
Description
MDN URL
https://developer.mozilla.org/en-US/docs/Web/API/WritableStream/abort
What specific section or headline is this issue about?
Return Value
What information was incorrect, unhelpful, or incomplete?
Currently, the docs state that WritableStream's Instance Method .abort(reason: any) returns a promise that resolves with reason.
AFAIK, this is incorrect.
What did you expect to see?
I believe it should be Promise<void> as indicated by the cross-engine tests below:
Do you have any supporting links, references, or citations?
Testing WritableStream.abort() with:
(() => {
console.log("=== Testing WritableStream.abort() return value ===\n");
const testReason = "test abort reason";
const writableStream = new WritableStream({
write(chunk) {
console.log("Write called with:", chunk);
},
close() {
console.log("Close called");
},
abort(err) {
console.log("Abort handler called with:", err);
},
});
writableStream.abort(testReason).then((result) => {
console.log("✓ WritableStream.abort() resolved with:", result);
console.log(" Type:", typeof result);
console.log(" Is undefined?", result === undefined);
console.log(" Equals reason?", result === testReason);
console.log("");
}).catch((err) => {
console.error("✗ WritableStream.abort() rejected with:", err);
console.log("");
});
console.log("\n=== Testing ReadableStream.cancel() return value ===\n");
const readableStream = new ReadableStream({
start(controller) {
controller.enqueue("initial data");
},
cancel(reason) {
console.log("Cancel handler called with:", reason);
},
});
readableStream.cancel(testReason).then((result) => {
console.log("✓ ReadableStream.cancel() resolved with:", result);
console.log(" Type:", typeof result);
console.log(" Is undefined?", result === undefined);
console.log(" Equals reason?", result === testReason);
console.log("");
}).catch((err) => {
console.error("✗ ReadableStream.cancel() rejected with:", err);
console.log("");
});
console.log("\n=== Testing WritableStream.abort() with undefined reason ===\n");
const writableStream2 = new WritableStream({
write(chunk) {},
abort(err) {
console.log("Abort handler called with:", err);
},
});
writableStream2.abort().then((result) => {
console.log("✓ WritableStream.abort() (no reason) resolved with:", result);
console.log(" Type:", typeof result);
console.log(" Is undefined?", result === undefined);
console.log("");
}).catch((err) => {
console.error("✗ WritableStream.abort() (no reason) rejected with:", err);
console.log("");
});
console.log("\n=== Testing abort() with object reason ===\n");
const objectReason = { code: "CUSTOM_ABORT", message: "Aborted by user" };
const writableStream3 = new WritableStream({
write(chunk) {},
abort(err) {
console.log("Abort handler called with:", err);
},
});
writableStream3.abort(objectReason).then((result) => {
console.log("✓ WritableStream.abort(object) resolved with:", result);
console.log(" Type:", typeof result);
console.log(" Is same object?", result === objectReason);
console.log(" Result:", result);
console.log("");
}).catch((err) => {
console.error("✗ WritableStream.abort(object) rejected with:", err);
console.log("");
});
console.log("=== End of tests ===");
console.log("\nNote: Check the console output above to verify return types.");
console.log("Expected findings:");
console.log("- WritableStream.abort(reason) should resolve with the reason parameter");
console.log("- ReadableStream.cancel(reason) should resolve with undefined");
})();in Deno, yields:
=== Testing WritableStream.abort() return value ===
=== Testing ReadableStream.cancel() return value ===
Cancel handler called with: test abort reason
=== Testing WritableStream.abort() with undefined reason ===
=== Testing abort() with object reason ===
=== End of tests ===
Note: Check the console output above to verify return types.
Expected findings:
- WritableStream.abort(reason) should resolve with the reason parameter
- ReadableStream.cancel(reason) should resolve with undefined
Abort handler called with: test abort reason
Abort handler called with: undefined
Abort handler called with: { code: "CUSTOM_ABORT", message: "Aborted by user" }
✓ ReadableStream.cancel() resolved with: undefined
Type: undefined
Is undefined? true
Equals reason? false
✓ WritableStream.abort() resolved with: undefined
Type: undefined
Is undefined? true
Equals reason? false
✓ WritableStream.abort() (no reason) resolved with: undefined
Type: undefined
Is undefined? true
✓ WritableStream.abort(object) resolved with: undefined
Type: undefined
Is same object? false
Result: undefined
in Node, yields:
=== Testing WritableStream.abort() return value ===
=== Testing ReadableStream.cancel() return value ===
Cancel handler called with: test abort reason
=== Testing WritableStream.abort() with undefined reason ===
=== Testing abort() with object reason ===
=== End of tests ===
Note: Check the console output above to verify return types.
Expected findings:
- WritableStream.abort(reason) should resolve with the reason parameter
- ReadableStream.cancel(reason) should resolve with undefined
Abort handler called with: test abort reason
Abort handler called with: undefined
Abort handler called with: { code: 'CUSTOM_ABORT', message: 'Aborted by user' }
✓ ReadableStream.cancel() resolved with: undefined
Type: undefined
Is undefined? true
Equals reason? false
✓ WritableStream.abort() resolved with: undefined
Type: undefined
Is undefined? true
Equals reason? false
✓ WritableStream.abort() (no reason) resolved with: undefined
Type: undefined
Is undefined? true
✓ WritableStream.abort(object) resolved with: undefined
Type: undefined
Is same object? false
Result: undefined
in Edge devtools console:
=== Testing WritableStream.abort() return value ===
VM43:30
=== Testing ReadableStream.cancel() return value ===
VM43:37 Cancel handler called with: test abort reason
VM43:52
=== Testing WritableStream.abort() with undefined reason ===
VM43:71
=== Testing abort() with object reason ===
VM43:93 === End of tests ===
VM43:94
Note: Check the console output above to verify return types.
VM43:95 Expected findings:
VM43:96 - WritableStream.abort(reason) should resolve with the reason parameter
VM43:97 - ReadableStream.cancel(reason) should resolve with undefined
VM43:15 Abort handler called with: test abort reason
VM43:57 Abort handler called with: undefined
VM43:78 Abort handler called with: {code: 'CUSTOM_ABORT', message: 'Aborted by user'}
VM43:42 ✓ ReadableStream.cancel() resolved with: undefined
VM43:43 Type: undefined
VM43:44 Is undefined? true
VM43:45 Equals reason? false
VM43:46
VM43:20 ✓ WritableStream.abort() resolved with: undefined
VM43:21 Type: undefined
VM43:22 Is undefined? true
VM43:23 Equals reason? false
VM43:24
VM43:62 ✓ WritableStream.abort() (no reason) resolved with: undefined
VM43:63 Type: undefined
VM43:64 Is undefined? true
VM43:65
VM43:83 ✓ WritableStream.abort(object) resolved with: undefined
VM43:84 Type: undefined
VM43:85 Is same object? false
VM43:86 Result: undefined
in Firefox devtools console:
=== Testing WritableStream.abort() return value ===
[debugger eval code:3:11](chrome://devtools/content/webconsole/debugger%20eval%20code)
=== Testing ReadableStream.cancel() return value ===
[debugger eval code:30:11](chrome://devtools/content/webconsole/debugger%20eval%20code)
Cancel handler called with: test abort reason [debugger eval code:37:15](chrome://devtools/content/webconsole/debugger%20eval%20code)
=== Testing WritableStream.abort() with undefined reason ===
[debugger eval code:52:11](chrome://devtools/content/webconsole/debugger%20eval%20code)
=== Testing abort() with object reason ===
[debugger eval code:71:11](chrome://devtools/content/webconsole/debugger%20eval%20code)
=== End of tests === [debugger eval code:93:11](chrome://devtools/content/webconsole/debugger%20eval%20code)
Note: Check the console output above to verify return types. [debugger eval code:94:11](chrome://devtools/content/webconsole/debugger%20eval%20code)
Expected findings: [debugger eval code:95:11](chrome://devtools/content/webconsole/debugger%20eval%20code)
- WritableStream.abort(reason) should resolve with the reason parameter [debugger eval code:96:11](chrome://devtools/content/webconsole/debugger%20eval%20code)
- ReadableStream.cancel(reason) should resolve with undefined [debugger eval code:97:11](chrome://devtools/content/webconsole/debugger%20eval%20code)
Abort handler called with: test abort reason [debugger eval code:15:15](chrome://devtools/content/webconsole/debugger%20eval%20code)
Abort handler called with: undefined [debugger eval code:57:15](chrome://devtools/content/webconsole/debugger%20eval%20code)
Abort handler called with:
Object { code: "CUSTOM_ABORT", message: "Aborted by user" }
[debugger eval code:78:15](chrome://devtools/content/webconsole/debugger%20eval%20code)
✓ WritableStream.abort() resolved with: undefined [debugger eval code:20:15](chrome://devtools/content/webconsole/debugger%20eval%20code)
Type: undefined [debugger eval code:21:15](chrome://devtools/content/webconsole/debugger%20eval%20code)
Is undefined? true [debugger eval code:22:15](chrome://devtools/content/webconsole/debugger%20eval%20code)
Equals reason? false [debugger eval code:23:15](chrome://devtools/content/webconsole/debugger%20eval%20code)
<empty string> [debugger eval code:24:15](chrome://devtools/content/webconsole/debugger%20eval%20code)
✓ WritableStream.abort() (no reason) resolved with: undefined [debugger eval code:62:15](chrome://devtools/content/webconsole/debugger%20eval%20code)
Type: undefined [debugger eval code:63:15](chrome://devtools/content/webconsole/debugger%20eval%20code)
Is undefined? true [debugger eval code:64:15](chrome://devtools/content/webconsole/debugger%20eval%20code)
<empty string> [debugger eval code:65:15](chrome://devtools/content/webconsole/debugger%20eval%20code)
✓ WritableStream.abort(object) resolved with: undefined [debugger eval code:83:15](chrome://devtools/content/webconsole/debugger%20eval%20code)
Type: undefined [debugger eval code:84:15](chrome://devtools/content/webconsole/debugger%20eval%20code)
Is same object? false [debugger eval code:85:15](chrome://devtools/content/webconsole/debugger%20eval%20code)
Result: undefined [debugger eval code:86:15](chrome://devtools/content/webconsole/debugger%20eval%20code)
<empty string> [debugger eval code:87:15](chrome://devtools/content/webconsole/debugger%20eval%20code)
✓ ReadableStream.cancel() resolved with: undefined [debugger eval code:42:15](chrome://devtools/content/webconsole/debugger%20eval%20code)
Type: undefined [debugger eval code:43:15](chrome://devtools/content/webconsole/debugger%20eval%20code)
Is undefined? true [debugger eval code:44:15](chrome://devtools/content/webconsole/debugger%20eval%20code)
Equals reason? false [debugger eval code:45:15](chrome://devtools/content/webconsole/debugger%20eval%20code)
<empty string> [debugger eval code:46:15](chrome://devtools/content/webconsole/debugger%20eval%20code)
undefined
Do you have anything more you want to share?
No response
Metadata
Metadata
Assignees
Labels
Content:WebAPIWeb API docsWeb API docsneeds triageTriage needed by staff and/or partners. Automatically applied when an issue is opened.Triage needed by staff and/or partners. Automatically applied when an issue is opened.