Solvedangular RC5 Breaking Change - Http UMD

I'm submitting a ... (check one with "x")

[ X] bug report
[ ] feature request
[ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question

Current behavior
Post RC5 upgrade, facing below error -

platform-browser.umd.js:937 EXCEPTION: TypeError: Cannot read property 'toString' of nullBrowserDomAdapter.logError @ platform-browser.umd.js:937BrowserDomAdapter.logGroup @ platform-browser.umd.js:947ExceptionHandler.call @ core.umd.js:4389next @ core.umd.js:9971schedulerFn @ core.umd.js:9168SafeSubscriber.__tryOrUnsub @ Subscriber.ts:240SafeSubscriber.next @ Subscriber.ts:192Subscriber._next @ Subscriber.ts:133Subscriber.next @ Subscriber.ts:93Subject._finalNext @ Subject.ts:154Subject._next @ Subject.ts:144Subject.next @ Subject.ts:90EventEmitter.emit @ core.umd.js:9156onError @ core.umd.js:9394onHandleError @ core.umd.js:9266ZoneDelegate.handleError @ zone.js:327Zone.runTask @ zone.js:259drainMicroTaskQueue @ zone.js:474ZoneTask.invoke @ zone.js:426
platform-browser.umd.js:937 STACKTRACE:BrowserDomAdapter.logError @ platform-browser.umd.js:937ExceptionHandler.call @ core.umd.js:4391next @ core.umd.js:9971schedulerFn @ core.umd.js:9168SafeSubscriber.__tryOrUnsub @ Subscriber.ts:240SafeSubscriber.next @ Subscriber.ts:192Subscriber._next @ Subscriber.ts:133Subscriber.next @ Subscriber.ts:93Subject._finalNext @ Subject.ts:154Subject._next @ Subject.ts:144Subject.next @ Subject.ts:90EventEmitter.emit @ core.umd.js:9156onError @ core.umd.js:9394onHandleError @ core.umd.js:9266ZoneDelegate.handleError @ zone.js:327Zone.runTask @ zone.js:259drainMicroTaskQueue @ zone.js:474ZoneTask.invoke @ zone.js:426
platform-browser.umd.js:937 TypeError: Cannot read property 'toString' of null
at Request.Body.text (http.umd.js:1138)
at Request.getBody (http.umd.js:1720)
at Observable.eval as _subscribe
at Observable.subscribe (Observable.ts:93)
at Observable._subscribe (Observable.ts:152)
at MapOperator.call (map.ts:54)
at Observable.subscribe (Observable.ts:93)
at Observable._subscribe (Observable.ts:152)
at CatchOperator.call (catch.ts:32)
at Observable.subscribe (Observable.ts:93)BrowserDomAdapter.logError @ platform-browser.umd.js:937ExceptionHandler.call @ core.umd.js:4392next @ core.umd.js:9971schedulerFn @ core.umd.js:9168SafeSubscriber.__tryOrUnsub @ Subscriber.ts:240SafeSubscriber.next @ Subscriber.ts:192Subscriber._next @ Subscriber.ts:133Subscriber.next @ Subscriber.ts:93Subject._finalNext @ Subject.ts:154Subject._next @ Subject.ts:144Subject.next @ Subject.ts:90EventEmitter.emit @ core.umd.js:9156onError @ core.umd.js:9394onHandleError @ core.umd.js:9266ZoneDelegate.handleError @ zone.js:327Zone.runTask @ zone.js:259drainMicroTaskQueue @ zone.js:474ZoneTask.invoke @ zone.js:426
zone.js:463 TypeError: Cannot read property 'toString' of null(…)consoleError @ zone.js:463drainMicroTaskQueue @ zone.js:477ZoneTask.invoke @ zone.js:426

Angular version: 2.0.0-rc.5

  • Browser: [all]
  • Language: [all | TypeScript 1.8.10 | ES5]
28 Answers

✔️Accepted Answer

For me, this turned out to be because I use Http#request directly with a RequestOptionsArgs that I constructed myself. I tried explicitly setting an empty body (body: "") and everything works again.

Other Answers:

basically, if you're using request options, you have to make a get request, you can't leave the body empty.

options = new RequestOptions({
    body: '',
    headers: this.noPreFlightHeaders,
    withCredentials: true
  });

It seems that if you remove headers.append("Content-Type", "application/json"); it works.

The following work-around seems to resolve the issue:
let options = new RequestOptions({ headers: headers, body: '' });

790
13

This bug seems to only occur when a Content-Type header is set. Here is a minimal reproduction of the problem.
http://plnkr.co/edit/uMQlKO7RKvyRVJ2Y1L6v?p=preview

More Issues: