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

Missing performance.now() implementation #274

Closed
farnabaz opened this issue Jun 19, 2024 · 5 comments
Closed

Missing performance.now() implementation #274

farnabaz opened this issue Jun 19, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@farnabaz
Copy link
Contributor

Environment

------------------------------
- Operating System: Darwin
- Node Version:     v20.12.2
- Nuxt Version:     3.12.3-28645501.2b6967fb
- CLI Version:      3.11.2-1718100309.03d4a54
- Nitro Version:    2.10.0-28644031.f6f23270
- Package Manager:  [email protected]
- Builder:          -
- User Config:      devtools
- Runtime Modules:  -
- Build Modules:    -

Reproduction

Repo: https://github.com/farnabaz/unenv-performance-now
Demo: https://nuxt-ot.nuxt.dev

Describe the bug

Some packages like @opentelemetry/core imports performance directly from perf_hooks and thus this import handles by unenv in non-node environments. The issue is that performance polyfill is not yet implemented (or at least performance.now is not implemented) and calling performance.now() return proxy function.

As the result, we get this error
Screenshot 2024-06-19 at 13 06 12

Additional context

No response

Logs

No response

@farnabaz farnabaz added the bug Something isn't working label Jun 19, 2024
@pi0
Copy link
Member

pi0 commented Jun 19, 2024

Thanks for nice reproduction.

We have implemented performance now and it is available in nightly channel and will be fore unenv v2 / nitro v3 / nuxt v4.

In the meantime i would suggest to manually add a polyfill to the apps.

@pi0 pi0 closed this as completed Jun 19, 2024
@farnabaz
Copy link
Contributor Author

Unfortunately, I can't use unenv-nightly because of structure change in dist directory regarding the internals.

In the meantime i would suggest to manually add a polyfill to the apps.

How can I add polyfill manually to mock the perf_hooks imports?

@pi0
Copy link
Member

pi0 commented Jun 19, 2024

structure change in dist directory regarding the internals.

Which files are breaking your project? If minor, we might add it for backward compatibility so you can leverage v2.

How can I add polyfill manually to mock the perf_hooks imports?

Configure unenv: { polyfills: {}} in nuxt/nito config and add something like this.

@farnabaz
Copy link
Contributor Author

Screenshot 2024-06-19 at 14 09 32 Seems that these files are moved inside `http/internal/` directory.

@pi0
Copy link
Member

pi0 commented Jun 19, 2024

Ah this is from h3... unjs/h3#781 should fix in h3/nuxt nightly channel. Please let me know if other conflicts happening.

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

2 participants