hookable icon indicating copy to clipboard operation
hookable copied to clipboard

Cannot read properties of undefined (reading 'run')

Open kaka-bo opened this issue 9 months ago • 4 comments

Environment

Node Version: v18.14.0 Nuxt Version: 3.14.1592

Reproduction

.

Describe the bug

Image In the Sentry report:Cannot read properties of undefined (reading 'run')

Additional context

No response

Logs


kaka-bo avatar Mar 24 '25 01:03 kaka-bo

Sorry, please provide a minimal reproduction so that we can debug.

kricsleo avatar Mar 30 '25 12:03 kricsleo

Sorry, please provide a minimal reproduction so that we can debug.

I cannot provide it as it is a random issue that occurs in the production environment. I think this is the issue in line 46 of the screenshot, where 'creatdTask (name)' returns' undefined ', and this problem only randomly appears in Google Chrome browser

kaka-bo avatar Mar 31 '25 02:03 kaka-bo

We experienced a similar issue on React Native. console.creatdTask does not exist in this runtime and leads to errors. We had to shim it in order to make our libraries that uses hookable work also on React Native:

/**
 * React Native does not polyfill `console.createTask`, which leads to errors in dependencies that rely on it
 * (e.g. unjs/hookable).
 */
if (!console.createTask) {
  console.createTask = () => ({
    run: fn => fn(),
  });
}

qnp avatar Jun 04 '25 15:06 qnp

console.creatdTask does not exist in this runtime and leads to errors

hookable inherently includes compatibility judgment, so theoretically it shouldn't be because of this. https://github.com/unjs/hookable/blob/a45a54c3ffd2dfcfa4dd053030547c78aca7460d/src/utils.ts#L64-L65

kricsleo avatar Jun 06 '25 13:06 kricsleo