2

I am working on a very tangled Angular 4.4 application. It blows up and this is the stack trace that I am getting:

ERROR Error: "[object Object]"
    resolvePromise http://localhost:4300/polyfills.bundle.js:7118
    resolvePromise http://localhost:4300/polyfills.bundle.js:7075
    scheduleResolveOrReject http://localhost:4300/polyfills.bundle.js:7179
    invokeTask http://localhost:4300/polyfills.bundle.js:6710
    onInvokeTask http://localhost:4300/vendor.bundle.js:370092
    invokeTask http://localhost:4300/polyfills.bundle.js:6709
    runTask http://localhost:4300/polyfills.bundle.js:6482
    drainMicroTaskQueue http://localhost:4300/polyfills.bundle.js:6888
    invokeTask http://localhost:4300/polyfills.bundle.js:6789
    invoke http://localhost:4300/polyfills.bundle.js:6774
    timer http://localhost:4300/polyfills.bundle.js:8568
vendor.bundle.js:367231:19

How can I get anything more meaningful that [object object] at line 367231 of bundle.js?

FWIW, this particular line is trying to console.log a values variable which turns out to be a function that returns empty string when executed. it seems to be code internal to angular because it has (c) Google all over the comments.

I have tried running ng serve --build-optimizer=false but it still optimizes. I don't see an option in my .angular-cli.json to toggle this either.

I also don't understand why it seems to build sourcemaps but they're not picked up to give a meaningful trace:

Date: 2019-12-17T14:39:51.960Z
Hash: 436f24accaf17c10807d
Time: 22366ms
chunk {inline} inline.bundle.js, inline.bundle.js.map (inline) 5.83 kB [entry] [rendered]
chunk {main} main.bundle.js, main.bundle.js.map (main) 332 kB {vendor} [initial] [rendered]
chunk {polyfills} polyfills.bundle.js, polyfills.bundle.js.map (polyfills) 365 kB {inline} [initial] [rendered]
chunk {styles} styles.bundle.js, styles.bundle.js.map (styles) 1.02 MB {inline} [initial] [rendered]
chunk {vendor} vendor.bundle.js, vendor.bundle.js.map (vendor) 15.4 MB [initial] [rendered]
abracadabrax
  • 153
  • 9
  • `[object Object]` is the default output of `toString()`. Override that for whatever object you want to output. Also, turn on sourcemaps in your bundler to get better stack traces. – Heretic Monkey Dec 17 '19 at 14:32
  • 1
    Does this answer your question? [How do I get a better stack trace on Angular errors](https://stackoverflow.com/questions/55171139/how-do-i-get-a-better-stack-trace-on-angular-errors) – Heretic Monkey Dec 17 '19 at 14:33
  • I can't seem to be able to disable-optimizer on ng serve with angular 4.4, and my angular-cli.json has a completely different structure that the one from that question. – abracadabrax Dec 17 '19 at 14:43
  • Oh wow, this seems to be because of Firefox... If using Chrome the error shows just fine. This is ridiculous. I hate Chrome but this and the memory footprint makes it really hard to use Firefox (it's sitting at 12GB RAM usage at the moment.) See https://stackoverflow.com/questions/51041301/resolver-emitting-error-error-error-object-object for a solution to `Error [object object]` – abracadabrax Dec 17 '19 at 14:58
  • @abracadabrax that RAM utilization hints for whole other issues ... – Martin Zeitler Dec 18 '19 at 07:27
  • @MartinZeitler that's probably from running an Angular dev website with livereloading enabled for the last week. That shouldn't be an issue though, Chrome copes fine with it for weeks on end. It saddens me because I want as little Google in my life as I can. – abracadabrax Dec 19 '19 at 08:58

1 Answers1

2

The solution is to use Chrome... As much as I think Chrome is bad for the internet, this fixed the problem. It shows the actual error rather than [object Object] and uses the sourcemaps to show the exact spot in the original code rather than in the minified bundled artifact.

abracadabrax
  • 153
  • 9