Skip to content

Commit 98b65b9

Browse files
authored
fix(util-user-agent-browser): window can be undefined (#2214)
In sandboxed environments (pure v8) `window` can be undefined. Should not fail. Actually should always check for `globalThis` instead, but IE 11 is still alive....
1 parent 0745502 commit 98b65b9

File tree

1 file changed

+1
-1
lines changed
  • packages/util-user-agent-browser/src

1 file changed

+1
-1
lines changed

packages/util-user-agent-browser/src/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export const defaultUserAgent = ({
1111
serviceId,
1212
clientVersion,
1313
}: DefaultUserAgentOptions): Provider<UserAgent> => async () => {
14-
const parsedUA = window?.navigator?.userAgent ? bowser.parse(window.navigator.userAgent) : undefined;
14+
const parsedUA = (typeof window !== 'undefined' && window?.navigator?.userAgent) ? bowser.parse(window.navigator.userAgent) : undefined;
1515
const sections: UserAgent = [
1616
// sdk-metadata
1717
["aws-sdk-js", clientVersion],

0 commit comments

Comments
 (0)