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 GitHub
parent 20cb0e8863
commit 812f2e4c22
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 52 additions and 4 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 }) => {