mirror of
https://github.com/denoland/deno.git
synced 2024-11-28 16:20:57 -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) {
|
function mapToCallback(context, callback, onError) {
|
||||||
const signal = context.abortController.signal;
|
const signal = context.abortController.signal;
|
||||||
const hasCallback = callback.length > 0;
|
|
||||||
const hasOneCallback = callback.length === 1;
|
|
||||||
|
|
||||||
return async function (req) {
|
return async function (req) {
|
||||||
// Get the response from the user-provided callback. If that fails, use onError. If that fails, return a fallback
|
// 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 innerRequest;
|
||||||
let response;
|
let response;
|
||||||
try {
|
try {
|
||||||
if (hasCallback) {
|
|
||||||
innerRequest = new InnerRequest(req, context);
|
innerRequest = new InnerRequest(req, context);
|
||||||
const request = fromInnerRequest(innerRequest, signal, "immutable");
|
|
||||||
if (hasOneCallback) {
|
|
||||||
response = await callback(request);
|
|
||||||
} else {
|
|
||||||
response = await callback(
|
response = await callback(
|
||||||
request,
|
fromInnerRequest(innerRequest, signal, "immutable"),
|
||||||
new ServeHandlerInfo(innerRequest),
|
new ServeHandlerInfo(innerRequest),
|
||||||
);
|
);
|
||||||
}
|
|
||||||
} else {
|
|
||||||
response = await callback();
|
|
||||||
}
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
try {
|
try {
|
||||||
response = await onError(error);
|
response = await onError(error);
|
||||||
|
|
Loading…
Reference in a new issue