Skip to content

Commit eec8800

Browse files
marvinhagemeistersatyarohith
authored andcommitted
fix: serve handler error with 0 arguments (#23652)
Fixes #23651 Co-authored-by: Satya Rohith <[email protected]>
1 parent a13c453 commit eec8800

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

ext/http/00_serve.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -793,9 +793,9 @@ internals.serveHttpOnConnection = serveHttpOnConnection;
793793

794794
function registerDeclarativeServer(exports) {
795795
if (ObjectHasOwn(exports, "fetch")) {
796-
if (typeof exports.fetch !== "function" || exports.fetch.length !== 1) {
796+
if (typeof exports.fetch !== "function") {
797797
throw new TypeError(
798-
"Invalid type for fetch: must be a function with a single parameter",
798+
"Invalid type for fetch: must be a function with a single or no parameter",
799799
);
800800
}
801801
return ({ servePort, serveHost }) => {

tests/testdata/serve/no_args.ts

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export default {
2+
fetch() {
3+
return new Response("deno serve with no args in fetch() works!");
4+
},
5+
};

0 commit comments

Comments
 (0)