1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-01-21 21:50:00 -05:00

fix: serve handler error with 0 arguments (#23652)

Fixes https://github.com/denoland/deno/issues/23651

Co-authored-by: Satya Rohith <me@satyarohith.com>
This commit is contained in:
Marvin Hagemeister 2024-05-17 14:35:19 +02:00 committed by Bartek Iwańczuk
parent a13c4531fd
commit eec8800513
No known key found for this signature in database
GPG key ID: 0C6BCDDC3B3AD750
2 changed files with 7 additions and 2 deletions

View file

@ -793,9 +793,9 @@ internals.serveHttpOnConnection = serveHttpOnConnection;
function registerDeclarativeServer(exports) {
if (ObjectHasOwn(exports, "fetch")) {
if (typeof exports.fetch !== "function" || exports.fetch.length !== 1) {
if (typeof exports.fetch !== "function") {
throw new TypeError(
"Invalid type for fetch: must be a function with a single parameter",
"Invalid type for fetch: must be a function with a single or no parameter",
);
}
return ({ servePort, serveHost }) => {

5
tests/testdata/serve/no_args.ts vendored Normal file
View file

@ -0,0 +1,5 @@
export default {
fetch() {
return new Response("deno serve with no args in fetch() works!");
},
};