Skip to content

Commit

Permalink
fix: If request does not have a static backend defined, return `undef…
Browse files Browse the repository at this point in the history
…ined` for the Request.prototype.backend getter (#722)
  • Loading branch information
JakeChampion committed Jan 25, 2024
1 parent 17fbdf5 commit 251c037
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
6 changes: 1 addition & 5 deletions runtime/js-compute-runtime/builtins/request-response.cpp
Expand Up @@ -1263,11 +1263,7 @@ bool Request::bodyAll(JSContext *cx, unsigned argc, JS::Value *vp) {
bool Request::backend_get(JSContext *cx, unsigned argc, JS::Value *vp) {
METHOD_HEADER(0)
JS::RootedValue backend(cx, JS::GetReservedSlot(self, static_cast<uint32_t>(Slots::Backend)));
if (backend.isNullOrUndefined()) {
args.rval().setString(JS_GetEmptyString(cx));
} else {
args.rval().set(backend);
}
args.rval().set(backend);

return true;
}
Expand Down
2 changes: 1 addition & 1 deletion types/globals.d.ts
Expand Up @@ -1084,7 +1084,7 @@ interface Request extends Body {
clone(): Request;

// Fastly extensions
backend: string;
backend?: string;
setCacheOverride(override: import('fastly:cache-override').CacheOverride): void;
setCacheKey(key: string): void;
setManualFramingHeaders(manual: boolean): void;
Expand Down

0 comments on commit 251c037

Please sign in to comment.