Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: userAgent is undefined with Cloudflare Workers #221

Closed
mpint opened this issue Mar 5, 2023 · 3 comments
Closed

Bug: userAgent is undefined with Cloudflare Workers #221

mpint opened this issue Mar 5, 2023 · 3 comments
Labels
bug Something isn't working

Comments

@mpint
Copy link

mpint commented Mar 5, 2023

Describe the bug
Hi there, 4.8.1 added isometric globalThis, but navigator doesn't exist in the Cloudflare Workers (and Vercel Edge Functions) runtime, so it still breaks.

const meta: IMetaStatic = {
  runtime: "Browser",
  browser: globalThis?.["navigator"].userAgent,
};
import { ILogObj, Logger } from "tslog"
export const logs: Logger<ILogObj> = new Logger()
logs.silly("Running website monitors")
// TypeError: Cannot read properties of undefined (reading 'userAgent')

To Reproduce

Basic hello-world in Cloudflare Workers

@mpint mpint added the bug Something isn't working label Mar 5, 2023
@terehov terehov closed this as completed in 2d9d74b Mar 5, 2023
@terehov
Copy link
Contributor

terehov commented Mar 5, 2023

Thank you. Check out V4.8.2. Does it work now?

@mpint
Copy link
Author

mpint commented Mar 6, 2023

Thanks for the quick response, but not quite! Now I'm seeing:

error TypeError: Cannot read properties of undefined (reading 'origin')
    at stackLineToStackFrame (node_modules/.pnpm/tslog@4.8.2/node_modules/tslog/dist/esm/runtime/browser/index.js:32:38)
    at getCallerStackFrame (node_modules/.pnpm/tslog@4.8.2/node_modules/tslog/dist/esm/runtime/browser/index.js:20:12)

It might be worth playing around with https://cloudflareworkers.com to see which globals the runtime provides.

@OultimoCoder
Copy link

Any update on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants