Skip to content

Commit

Permalink
fix: better isPromise check for proxy objects (#11178)
Browse files Browse the repository at this point in the history
  • Loading branch information
theoephraim authored Jun 5, 2024
1 parent 3cfa2ac commit 1734c49
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/green-moose-fetch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'astro': patch
---

Improves `isPromise` utility to check the presence of `then` on an object before trying to access it - which can cause undesired side-effects on Proxy objects
2 changes: 1 addition & 1 deletion packages/astro/src/runtime/server/util.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export function isPromise<T = any>(value: any): value is Promise<T> {
return !!value && typeof value === 'object' && typeof value.then === 'function';
return !!value && typeof value === 'object' && 'then' in value && typeof value.then === 'function';
}

export async function* streamAsyncIterator(stream: ReadableStream) {
Expand Down

0 comments on commit 1734c49

Please sign in to comment.