someApprentice / Crypter

3 stars 1 forks source link

Angular throws a http errors in browser console even if they are caught in application #1

Open someApprentice opened 5 years ago

someApprentice commented 5 years ago

When authorization is failed API respond 404 status code and for this case an applications catches an error

https://github.com/someApprentice/Crypter/blob/master/src/app/auth/auth.service.ts#L36 https://github.com/someApprentice/Crypter/blob/master/src/app/auth/auth.service.ts#L61-L63

But somehow Angular throws the error anyway

POST http://localhost:4000/api/login 404 (Not Found)
_ @ polyfills.1ef83d22ada557f4a131.js:1
n.scheduleTask @ polyfills.1ef83d22ada557f4a131.js:1
onScheduleTask @ polyfills.1ef83d22ada557f4a131.js:1
n.scheduleTask @ polyfills.1ef83d22ada557f4a131.js:1
t.scheduleTask @ polyfills.1ef83d22ada557f4a131.js:1
t.scheduleMacroTask @ polyfills.1ef83d22ada557f4a131.js:1
p @ polyfills.1ef83d22ada557f4a131.js:1
(anonymous) @ polyfills.1ef83d22ada557f4a131.js:1
H.a.(anonymous function) @ polyfills.1ef83d22ada557f4a131.js:1
(anonymous) @ main.1ce17900a4d53c7a028c.js:1
t._trySubscribe @ main.1ce17900a4d53c7a028c.js:1
t.subscribe @ main.1ce17900a4d53c7a028c.js:1
(anonymous) @ main.1ce17900a4d53c7a028c.js:1
J @ main.1ce17900a4d53c7a028c.js:1
e._innerSub @ main.1ce17900a4d53c7a028c.js:1
e._tryNext @ main.1ce17900a4d53c7a028c.js:1
e._next @ main.1ce17900a4d53c7a028c.js:1
e.next @ main.1ce17900a4d53c7a028c.js:1
(anonymous) @ main.1ce17900a4d53c7a028c.js:1
t._trySubscribe @ main.1ce17900a4d53c7a028c.js:1
t.subscribe @ main.1ce17900a4d53c7a028c.js:1
t.call @ main.1ce17900a4d53c7a028c.js:1
t.subscribe @ main.1ce17900a4d53c7a028c.js:1
t.call @ main.1ce17900a4d53c7a028c.js:1
t.subscribe @ main.1ce17900a4d53c7a028c.js:1
t.call @ main.1ce17900a4d53c7a028c.js:1
t.subscribe @ main.1ce17900a4d53c7a028c.js:1
t.call @ main.1ce17900a4d53c7a028c.js:1
t.subscribe @ main.1ce17900a4d53c7a028c.js:1
t.call @ main.1ce17900a4d53c7a028c.js:1
t.subscribe @ main.1ce17900a4d53c7a028c.js:1
t.login @ main.1ce17900a4d53c7a028c.js:1
(anonymous) @ main.1ce17900a4d53c7a028c.js:1
handleEvent @ main.1ce17900a4d53c7a028c.js:1
handleEvent @ main.1ce17900a4d53c7a028c.js:1
ea @ main.1ce17900a4d53c7a028c.js:1
(anonymous) @ main.1ce17900a4d53c7a028c.js:1
e.object.o @ main.1ce17900a4d53c7a028c.js:1
e.__tryOrUnsub @ main.1ce17900a4d53c7a028c.js:1
e.next @ main.1ce17900a4d53c7a028c.js:1
e._next @ main.1ce17900a4d53c7a028c.js:1
e.next @ main.1ce17900a4d53c7a028c.js:1
e.next @ main.1ce17900a4d53c7a028c.js:1
e.emit @ main.1ce17900a4d53c7a028c.js:1
e.onSubmit @ main.1ce17900a4d53c7a028c.js:1
(anonymous) @ main.1ce17900a4d53c7a028c.js:1
handleEvent @ main.1ce17900a4d53c7a028c.js:1
handleEvent @ main.1ce17900a4d53c7a028c.js:1
ea @ main.1ce17900a4d53c7a028c.js:1
(anonymous) @ main.1ce17900a4d53c7a028c.js:1
(anonymous) @ main.1ce17900a4d53c7a028c.js:1
n.invokeTask @ polyfills.1ef83d22ada557f4a131.js:1
onInvokeTask @ main.1ce17900a4d53c7a028c.js:1
n.invokeTask @ polyfills.1ef83d22ada557f4a131.js:1
t.runTask @ polyfills.1ef83d22ada557f4a131.js:1
t.invokeTask @ polyfills.1ef83d22ada557f4a131.js:1
k @ polyfills.1ef83d22ada557f4a131.js:1
g @ polyfills.1ef83d22ada557f4a131.js:1

Importing the zone.js/dist/zone-error in environment files doesn't actually affects anything.

This behavior isn't occurs in the test environment via Karma/Jasmine.

someApprentice commented 5 years ago

Stack trace from prod:

POST http://localhost:4000/api/login 404 (Not Found)

  | scheduleTask | @ | zone.js:2969
-- | -- | -- | --
  | push../node_modules/zone.js/dist/zone.js.ZoneDelegate.scheduleTask | @ | zone.js:407
  | onScheduleTask | @ | zone.js:297
  | push../node_modules/zone.js/dist/zone.js.ZoneDelegate.scheduleTask | @ | zone.js:401
  | push../node_modules/zone.js/dist/zone.js.Zone.scheduleTask | @ | zone.js:232
  | push../node_modules/zone.js/dist/zone.js.Zone.scheduleMacroTask | @ | zone.js:255
  | scheduleMacroTaskWithCurrentZone | @ | zone.js:1114
  | (anonymous) | @ | zone.js:3001
  | proto.(anonymous function) | @ | zone.js:1394
  | (anonymous) | @ | http.js:1630
  | push../node_modules/rxjs/_esm5/internal/Observable.js.Observable._trySubscribe | @ | Observable.js:43
  | push../node_modules/rxjs/_esm5/internal/Observable.js.Observable.subscribe | @ | Observable.js:29
  | (anonymous) | @ | subscribeTo.js:21
  | subscribeToResult | @ | subscribeToResult.js:11
  | push../node_modules/rxjs/_esm5/internal/operators/mergeMap.js.MergeMapSubscriber._innerSub | @ | mergeMap.js:74
  | push../node_modules/rxjs/_esm5/internal/operators/mergeMap.js.MergeMapSubscriber._tryNext | @ | mergeMap.js:68
  | push../node_modules/rxjs/_esm5/internal/operators/mergeMap.js.MergeMapSubscriber._next | @ | mergeMap.js:51
  | push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber.next | @ | Subscriber.js:54
  | (anonymous) | @ | scalar.js:5
  | push../node_modules/rxjs/_esm5/internal/Observable.js.Observable._trySubscribe | @ | Observable.js:43
  | push../node_modules/rxjs/_esm5/internal/Observable.js.Observable.subscribe | @ | Observable.js:29
  | push../node_modules/rxjs/_esm5/internal/operators/mergeMap.js.MergeMapOperator.call | @ | mergeMap.js:29
  | push../node_modules/rxjs/_esm5/internal/Observable.js.Observable.subscribe | @ | Observable.js:24
  | push../node_modules/rxjs/_esm5/internal/operators/filter.js.FilterOperator.call | @ | filter.js:15
  | push../node_modules/rxjs/_esm5/internal/Observable.js.Observable.subscribe | @ | Observable.js:24
  | push../node_modules/rxjs/_esm5/internal/operators/map.js.MapOperator.call | @ | map.js:18
  | push../node_modules/rxjs/_esm5/internal/Observable.js.Observable.subscribe | @ | Observable.js:24
  | push../node_modules/rxjs/_esm5/internal/operators/tap.js.DoOperator.call | @ | tap.js:18
  | push../node_modules/rxjs/_esm5/internal/Observable.js.Observable.subscribe | @ | Observable.js:24
  | push../node_modules/rxjs/_esm5/internal/operators/catchError.js.CatchOperator.call | @ | catchError.js:18
  | push../node_modules/rxjs/_esm5/internal/Observable.js.Observable.subscribe | @ | Observable.js:24
  | push../src/app/auth/login/login.component.ts.LoginComponent.login | @ | login.component.ts:46
  | (anonymous) | @ | LoginComponent.html:1
  | handleEvent | @ | core.js:21673
  | callWithDebugContext | @ | core.js:22767
  | debugHandleEvent | @ | core.js:22470
  | dispatchEvent | @ | core.js:19122
  | (anonymous) | @ | core.js:20612
  | schedulerFn | @ | core.js:12621
  | push../node_modules/rxjs/_esm5/internal/Subscriber.js.SafeSubscriber.__tryOrUnsub | @ | Subscriber.js:196
  | push../node_modules/rxjs/_esm5/internal/Subscriber.js.SafeSubscriber.next | @ | Subscriber.js:134
  | push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber._next | @ | Subscriber.js:77
  | push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber.next | @ | Subscriber.js:54
  | push../node_modules/rxjs/_esm5/internal/Subject.js.Subject.next | @ | Subject.js:47
  | push../node_modules/@angular/core/fesm5/core.js.EventEmitter.emit | @ | core.js:12593
  | push../node_modules/@angular/forms/fesm5/forms.js.FormGroupDirective.onSubmit | @ | forms.js:5253
  | (anonymous) | @ | LoginComponent.html:1
  | handleEvent | @ | core.js:21673
  | callWithDebugContext | @ | core.js:22767
  | debugHandleEvent | @ | core.js:22470
  | dispatchEvent | @ | core.js:19122
  | (anonymous) | @ | core.js:19569
  | (anonymous) | @ | platform-browser.js:993
  | push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask | @ | zone.js:421
  | onInvokeTask | @ | core.js:16147
  | push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask | @ | zone.js:420
  | push../node_modules/zone.js/dist/zone.js.Zone.runTask | @ | zone.js:188
  | push../node_modules/zone.js/dist/zone.js.ZoneTask.invokeTask | @ | zone.js:496
  | invokeTask | @ | zone.js:1540
  | globalZoneAwareCallback | @ | zone.js:1566