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

Exception has occurred: TypeError: Cannot assign to read only property 'name'... #564

Closed
justuscook opened this issue Mar 15, 2021 · 7 comments

Comments

@justuscook
Copy link

Describe the bug

Exception has occurred: TypeError: Cannot assign to read only property 'name' of function 'function generateUUID(value, namespace, buf, offset) {
    if (typeof value === 'string') {
      value = strin...<omitted>... }'

How to reproduce

I'm not what to put here, this is throwing the error referencing my main JS file, but that file has no reference to the uuid functions.

Expected behavior

To not give this error lol.

Runtime

Node.js 14.15.5

@TrySound
Copy link
Member

This is weird. We have guard for this. https://github.com/uuidjs/uuid/blob/master/src/v35.js#L57-L61
Which version of uuid do you use?

@justuscook
Copy link
Author

justuscook commented Mar 15, 2021

I just realized the try catch in the lib, i had caught exception on in my debugger, my apologies.

@Duckers
Copy link

Duckers commented Mar 21, 2021

Is this really necessary? Even when not using v35 I get this super annoying error all the time when running with debugger

@broofa
Copy link
Member

broofa commented Mar 21, 2021

Is this really necessary?

Good question. The try-catch was added to address #268.

As for why name is set, that was added at my request in the original PR to "Set function name shown in debuggers". See #217 (comment). Without this, v3 and v5 would both show up in stacktraces as generateUUID.

I.e. it's basically for cosmetic reasons when debugging code that calls v3 or v5 and is not strictly necessary.

... and relatively few people use v3 or v5. (I think it's something like 1% of uuid users?)

That said...

Even when not using v35 I get this super annoying error all the time when running with debugger

  1. If you're not using v35 and you're code uses ESM imports, a tree shaking bundler (e.g. parcel/rollup/webpack) should remove this code.

  2. This code is only called (twice) on module load, not each time a uuid is created. And if you've set your debugger to pause on caught exceptions (which is the only time this is an issue, right?) I expect this is hardly the only place you're running into this issue. Wrapping feature-specific code in a try-catch is standard practice. It's done all the time, in all sorts of modules. While I agree it's frustrating (on the rare occasions there is reason to break on caught exceptions), the problem is by no means specific to uuid. I.e. It kinda comes with the territory.

@rbrandino1
Copy link

I just realized the try catch in the lib, i had caught exception on in my debugger, my apologies.

Same here!

@rezshek
Copy link

rezshek commented Jun 30, 2022

Is this really necessary? Even when not using v35 I get this super annoying error all the time when running with a debugger

Same here, any way around it?
I'm trying to connect to Cosmos DB with @azure/client and this is what happens as soon as I hot the API that I have there.

@LarryStewart2022
Copy link

LarryStewart2022 commented May 30, 2023

Same error.... :-(
Exception has occurred: TypeError: Cannot assign to read only property 'name' of function 'function generateUUID(value, namespace, buf, offset) {
var _namespace;

if (typeof value === 'string') ...<omitted>... }'

at v35 (C:\LANGCHAIN\node_modules\uuid\dist\v35.js:73:23)
at Object. (C:\LANGCHAIN\node_modules\uuid\dist\v3.js:14:27)
at Module._compile (node:internal/modules/cjs/loader:1254:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1308:10)
at Module.load (node:internal/modules/cjs/loader:1117:32)
at Module._load (node:internal/modules/cjs/loader:958:12)
at Module.require (node:internal/modules/cjs/loader:1141:19)
at require (node:internal/modules/cjs/helpers:110:18)
at Object. (C:\LANGCHAIN\node_modules\uuid\dist\index.js:63:34)
at Module._compile (node:internal/modules/cjs/loader:1254:14)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants