How to debug zone.js exception? - javascript

I have a Angular 2 TypeScript project. I have updated all of the packages and built the project.
Now I see this error in the console:
zone.js:1265 Uncaught TypeError: Cannot read property 'apply' of undefined
at XMLHttpRequest.desc.get [as ontimeout] (zone.js:1265)
at XHRLocalObject.AbstractXHRObject._cleanup (abstract-xhr.js:149)
at XMLHttpRequest.xhr.onreadystatechange (abstract-xhr.js:125)
at XMLHttpRequest.wrapFn (zone.js:1230)
at ZoneDelegate.invokeTask (zone.js:398)
at Zone.runTask (zone.js:165)
at XMLHttpRequest.ZoneTask.invoke (zone.js:460)
So I can't figure out where the error is in the project code, because there is no project code in the stack trace. There are many HTTP requests at the start. They all succeed (no errors in the network tab), but I see that there is actually no data: no content for <select>. I would like to avoid having to go through my code, removing parts of it and testing whether the error is still there.
Is there any way to figure out where my code is causing this error?

What you describe is a recent issue in the v0.8.8 of Zone.js. See the GitHub issue here. The easiest way for you to avoid this would be to downgrade to 0.8.5 version.
To do this, using npm, just use this command:
npm install zone.js#0.8.5
and consider adding --save at the end of the command to add it to your JSON dependencies.

Alexander is right: check your package.json if there is something like this in there:
...
"zone.js": "^0.8...."
Change the version to something below 0.8.8. This fixed it for me.

Related

Error when trying to run any Cypress test

I've installed Cypress according to the cypress docs. After opening Cypress and selecting a test to run, I instantly get the following error:
**Title:** Error running plugin
Message: The following error was thrown by a plugin. We stopped running your tests because a plugin crashed. Please check your plugins file (C:\Users\metin\Desktop\Programming\School\Typescript\From JS to TS\cypress\plugins\index.js)
Stack trace:
Error: The following error was thrown by a plugin. We stopped running your tests because a plugin crashed. Please check your plugins file (`C:\Users\metin\Desktop\Programming\School\Typescript\From JS to TS\cypress\plugins\index.js`)
at Object.get (C:\Users\metin\AppData\Local\Cypress\Cache\9.1.0\Cypress\resources\app\packages\server\lib\errors.js:1043:15)
at EventEmitter.handleError (C:\Users\metin\AppData\Local\Cypress\Cache\9.1.0\Cypress\resources\app\packages\server\lib\plugins\index.js:189:20)
at EventEmitter.emit (node:events:394:28)
at ChildProcess.<anonymous> (C:\Users\metin\AppData\Local\Cypress\Cache\9.1.0\Cypress\resources\app\packages\server\lib\plugins\util.js:19:22)
at ChildProcess.emit (node:events:394:28)
at emit (node:internal/child_process:920:12)
at processTicksAndRejections (node:internal/process/task_queues:84:21)
I've been googling for a few hours and I'm looking for help on how to resolve this issue!
Uninstall Nodejs
Download the Nodejs (Recommended For Most Users) version from the link:
https://nodejs.org/en/
Install the downloaded Nodejs
I had the same issues
in my case, this issue was related to my bitbucket.yml.file, I changed: max-time:(set time for running your tests) in my job, and everything works fine
If you're using Cucumber then review your step files in search of misspelling keywords or case sensitive typos like wHEN or thEn

Getting EISDIR error from NodeJS when attempting to start app via Expo (React Native)

I'm getting the old 'directory is not a file' error with Node, and the output does not make it clear what exactly it's trying to parse. I've tried putting logging in and everything to find the issue, and even created a brand new project but the issue persists. Can anyone shed any light on this?
Error: EISDIR: illegal operation on a directory, read
at Object.readSync (fs.js:592:3)
at tryReadSync (fs.js:366:20)
at Object.readFileSync (fs.js:403:19)
at UnableToResolveError.buildCodeFrameMessage (C:\Users\thepo\Applications\WakeMyPC\node_modules\metro\src\node-haste\DependencyGraph\ModuleResolution.js:304:17)
at new UnableToResolveError (C:\Users\thepo\Applications\WakeMyPC\node_modules\metro\src\node-haste\DependencyGraph\ModuleResolution.js:290:35)
at ModuleResolver.resolveDependency (C:\Users\thepo\Applications\WakeMyPC\node_modules\metro\src\node-haste\DependencyGraph\ModuleResolution.js:168:15)
at DependencyGraph.resolveDependency (C:\Users\thepo\Applications\WakeMyPC\node_modules\metro\src\node-haste\DependencyGraph.js:353:43)
at C:\Users\thepo\Applications\WakeMyPC\node_modules\metro\src\lib\transformHelpers.js:271:42
at C:\Users\thepo\Applications\WakeMyPC\node_modules\metro\src\Server.js:1098:37
at Generator.next (<anonymous>)
The problem turned out to be that some of the versions of modules that I installed using npm were not compatible with expo. These were indicated earlier than the error in the output for the 'expo start' command. Because these were info logs, I didn't pay enough attention to them. However, after several hours I decided to fix them and it fixed my problem.
The fix was to follow each individual package named in the output and run 'expo install '.
Make sure the entryPoint key in your app.config.js or app.json file is correctly set.
I had an intermittent error very similar to this and it was related to a bug with remote debugging.
Turning off "Debug Remote JS" in the Expo Go app shake-to-show developer menu avoided this issue for me (logs and errors still show in the Metro console).
Here's the exact error message I was getting (and sometimes the app would just fail silently without any error). It's almost identical to the error in the question with a few different line numbers (maybe from different versions).
Error: EISDIR: illegal operation on a directory, read
at Object.readSync (node:fs:721:3)
at tryReadSync (node:fs:431:20)
at Object.readFileSync (node:fs:477:19)
at UnableToResolveError.buildCodeFrameMessage
As for "why", there's some related discussion on this expo forum thread which in turn links to this React Native bug (claimed to be fixed in Expo CLI 4.13.1 but many users reporting similar issues in recent versions).
It might be related to the reported issues with Reanimated 2 and Expo's remote debugging (see this reanimated issue and the warning note in Expo's documentation) for Reanimated.

Uncaught TypeError: t.rgb is not a function

Uncaught TypeError: t.rgb is not a function
I created an angular application, built it, and am attempting to serve it
$ ng serve --prod --aot
This results in the following error in the console
Uncaught TypeError: t.rgb is not a function
at HO (color.js.pre-build-optimizer.js:227)
at GO (color.js.pre-build-optimizer.js:232)
at rgb.js.pre-build-optimizer.js:36
at RH (ramp.js.pre-build-optimizer.js:4)
at Module.zUnb (BrBG.js.pre-build-optimizer.js:16)
at f (bootstrap:78)
at Object.0 (index.js.pre-build-optimizer.js:26)
at f (bootstrap:78)
at t (bootstrap:45)
at Array.r [as push] (bootstrap:32)
The application does not display
When I build the application without minifying (the --prod flag) it works.
I am only seeing this issue when using D3
D3 ^5.9.1 .
Angular version 7.3.9 .
typescript 3.2.4
I have tried many combinations of versions with no luck.
It also runs successfully when I pass --optimization=false
I have been unable to debug this so far. This is very similar to this question however the solutions does not apply to this situation
Please let me know if any additional information would be useful.
Update your version of #angular-devkit/build-angular
(just found it here).
I have downgraded the version of d3 to 4.13.0 instead of 5.9.2.
npm install d3#4.13.0
The issue is d3-color.
Hope it helped.

How to fix 'TypeError: Cannot read property 'fn' of undefined" and 'Unable to require Taiko"

Trying to run gauge with taiko to automate some web testing. sudo gauge run specs throws two type errors and "Unable to require Taiko"
Taiko, nodejs, npm are installed and working fine. Gauge seems mostly fine. gauge init js worked.
I've tried moving the .spec file into different dirs, and moving taiko and nodejs around, with no difference.
To replicate, with everything necessary installed:
gauge init js
gauge run specs
Should run the .spec file created by 'init'
Actually output too long to include, but will show on request.
Errors:
1)
Unable to require module 'taiko' in /home/harry/tests/step_implementation.js
Trace: Error: Cannot find module 'taiko'
Require stack:
- /home/harry/tests/step_implementation.js
2)
const { openBrowser,write, closeBrowser, goto, press, text, focus, inputField, toRightOf } = require('taiko');
^
TypeError: Cannot destructure property `openBrowser` of 'undefined' or 'null'.
3)
new Test(step.fn, parameters, timeout).run().then(
^
TypeError: Cannot read property 'fn' of undefined
4)
[Gauge]
Connection to runner with Pid 15653 lost. The runner probably quit unexpectedly.
You should check your node_modules once. This kind of error happens when you don't have taiko in your node_modules.
When you do gauge init js it is added to your local node_modules. Something might have messed up so I guess Taiko is not in your node_modules try running
npm install --save taiko. This might solve your issue. Thanks.
Whats the file, the context, the OS>.. the reason why is because the monikier is mangled...
undefined is a result of a charset mismatch of some syymbolc IMHO...
Trace: Error: Cannot find module 'taiko' completely tells you that taiko is not installed , run npm i taiko and try again.

Cordova Build error: nodeValue undefined

After a couple of days without touching my app, today when I tried to build it I got the following error:
Error thrown while running shell command: "cordova build ios"
Error: Command failed: /bin/sh -c cordova build ios
Error: Cannot read property 'nodeValue' of undefined
If I remove the ios platform and add it again, it will work, but that's not the best solution... I'd like to understand the issue.
Do you have any idea what might have caused this error and what would be the best solution to fix it?
Thanks.
I just got this exact same error. For me the cause was that in my MyApp-info.plist I had added a new line that was empty, basically there was a blank key-value pair like this:
<key></key>
<string></string>
Once I removed this, the error disappeared and cordova was able to build again.
Hope that helps!

Categories