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

TypeError: Cannot assign to read only property 'Symbol(Symbol.toStringTag)' of object '#<WeakMap>' #5871

Closed
sainnhe opened this issue May 27, 2024 · 3 comments

Comments

@sainnhe
Copy link

sainnhe commented May 27, 2024

Hi, thanks for your work. I'm using a nodejs based application named coc-explorer, which is a vim extension, but I encountered a bug:

2024-05-27T22:24:39.197 ERROR (pid:115475) [extension-stat] - Error on parse json file /home/sainnhe/.local/share/nvim/coc/extensions/package.json TypeError: Cannot assign to read only property 'Symbol(Symbol.toStringTag)' of object '#<WeakMap>'
    at getRawTag (/home/sainnhe/.local/share/nvim/coc/extensions/node_modules/coc-explorer/lib/index.js:6127:27)
    at baseGetTag (/home/sainnhe/.local/share/nvim/coc/extensions/node_modules/coc-explorer/lib/index.js:6159:64)
    at Object.<anonymous> (/home/sainnhe/.local/share/nvim/coc/extensions/node_modules/coc-explorer/lib/index.js:7314:292)
    at Module.<anonymous> (/home/sainnhe/.local/share/nvim/plugins/coc.nvim/build/index.js:77963:28)
    at Module._extensions..js (node:internal/modules/cjs/loader:1427:10)
    at Module.load (node:internal/modules/cjs/loader:1206:32)
    at Module._load (node:internal/modules/cjs/loader:1022:12)
    at Module.require (node:internal/modules/cjs/loader:1231:19)
    at Object.sandboxRequire [as require] (/home/sainnhe/.local/share/nvim/plugins/coc.nvim/build/index.js:78002:42)
    at createExtension (/home/sainnhe/.local/share/nvim/plugins/coc.nvim/build/index.js:78035:33)

It seems to be a bug of lodash, since the content of /home/sainnhe/.local/share/nvim/coc/extensions/node_modules/coc-explorer/lib/index.js:6127:27 is as follows:

// node_modules/lodash-es/_getRawTag.js
var objectProto = Object.prototype;
var hasOwnProperty = objectProto.hasOwnProperty;
var nativeObjectToString = objectProto.toString;
var symToStringTag = Symbol_default ? Symbol_default.toStringTag : void 0;
function getRawTag(value) {
  var isOwn = hasOwnProperty.call(value, symToStringTag), tag = value[symToStringTag];
  try {
    value[symToStringTag] = void 0;
    var unmasked = true;
  } catch (e2) {
  }
  var result = nativeObjectToString.call(value);
  if (unmasked) {
    if (isOwn) {
      value[symToStringTag] = tag;
    } else {
      delete value[symToStringTag];
    }
  }
  return result;
}
var getRawTag_default = getRawTag;

Could you have a look at this bug? Thanks!

For more information weirongxu/coc-explorer#584

@sainnhe
Copy link
Author

sainnhe commented May 28, 2024

I can confirm that this bug is caused by line:

value[symToStringTag] = void 0;

The source code is located in tag 4.17.21-es

lodash/_getRawTag.js

Lines 26 to 44 in 11eb817

function getRawTag(value) {
var isOwn = hasOwnProperty.call(value, symToStringTag),
tag = value[symToStringTag];
try {
value[symToStringTag] = undefined;
var unmasked = true;
} catch (e) {}
var result = nativeObjectToString.call(value);
if (unmasked) {
if (isOwn) {
value[symToStringTag] = tag;
} else {
delete value[symToStringTag];
}
}
return result;
}

Seems like this property is read-only and cannot be altered.

@sainnhe
Copy link
Author

sainnhe commented May 28, 2024

After some investigations, I find that this bug seems to be caused by fedora linux package (I'm using nodejs package and the version is 20.12.2). The code is placed in a try-catch statement and should be catched by node, but it didn't.

I tried the official binary release on nodejs website and this issue doesn't exist.

@sainnhe
Copy link
Author

sainnhe commented May 28, 2024

Confirmed this is a packaging issue in fedora. Closed.

@sainnhe sainnhe closed this as completed May 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant