mirror of
https://github.com/denoland/deno.git
synced 2024-12-26 00:59:24 -05:00
fix(ext/http): patch regression in variadic args to serve handler (#20796)
I'm not sure what was the purpose of trying to be so clever with the args were (maybe an optimization?), but it breaks variadic args as pointed out in #20054. Signed-off-by: Matt Mastracci <matthew@mastracci.com> Co-authored-by: Matt Mastracci <matthew@mastracci.com>
This commit is contained in:
parent
9ec18c35c7
commit
33565e16ca
1 changed files with 5 additions and 16 deletions
|
@ -435,8 +435,6 @@ function fastSyncResponseOrStream(req, respBody, status) {
|
|||
*/
|
||||
function mapToCallback(context, callback, onError) {
|
||||
const signal = context.abortController.signal;
|
||||
const hasCallback = callback.length > 0;
|
||||
const hasOneCallback = callback.length === 1;
|
||||
|
||||
return async function (req) {
|
||||
// Get the response from the user-provided callback. If that fails, use onError. If that fails, return a fallback
|
||||
|
@ -444,20 +442,11 @@ function mapToCallback(context, callback, onError) {
|
|||
let innerRequest;
|
||||
let response;
|
||||
try {
|
||||
if (hasCallback) {
|
||||
innerRequest = new InnerRequest(req, context);
|
||||
const request = fromInnerRequest(innerRequest, signal, "immutable");
|
||||
if (hasOneCallback) {
|
||||
response = await callback(request);
|
||||
} else {
|
||||
response = await callback(
|
||||
request,
|
||||
new ServeHandlerInfo(innerRequest),
|
||||
);
|
||||
}
|
||||
} else {
|
||||
response = await callback();
|
||||
}
|
||||
innerRequest = new InnerRequest(req, context);
|
||||
response = await callback(
|
||||
fromInnerRequest(innerRequest, signal, "immutable"),
|
||||
new ServeHandlerInfo(innerRequest),
|
||||
);
|
||||
} catch (error) {
|
||||
try {
|
||||
response = await onError(error);
|
||||
|
|
Loading…
Reference in a new issue