Open Bug 943157 Opened 11 years ago Updated 2 years ago

Assertion Failing when JSON response is null

Categories

(Core :: DOM: Core & HTML, defect, P4)

x86
macOS
defect

Tracking

()

People

(Reporter: mchang, Unassigned)

Details

This assertion is failing:

jsval
XMLHttpRequest::GetResponse(JSContext* /* unused */, ErrorResult& aRv)
{
  if (NS_SUCCEEDED(mStateData.mResponseTextResult) &&
      JSVAL_IS_VOID(mStateData.mResponse)) {
    MOZ_ASSERT(mStateData.mResponseText.Length());

This occurs when returning null/undefined value from an XHR request. If the JSVAL_IS_VOID, the response is already void.
> This occurs when returning null/undefined value from an XHR request. 

In what sense?  What is the server actually sending?

Or better yet, a link to a page that shows the problem?
Flags: needinfo?(mchang)
This is on the Gaia Email Libs and More test suite. Something changed in Gecko within the past 2 weeks because tests were passing on debug builds for both mozilla-aurora and mozilla-central in early November.

Essentially, the test suite creates a fake imap server, and the imap server responds to an XHR request by returning literal 'null' or 'undefined' instead of an empty JSON {}. I think this is triggering this assertion.

Andrew, maybe you can give a little more context, if I'm on the right track?
Flags: needinfo?(bugmail)
Flags: needinfo?(mchang)
> Something changed in Gecko within the past 2 weeks 

OK, can you bisect to find out what?

I mean, I can spend a bunch of time auditing code and trying to guess what your server is sending, but if you control the server and can actually reproduce, it would be much simpler if you simply debug or provide a packet trace or something....
Oh, and for anyone else looking: and important piece of information missing from comment 0 is that this is XHR in a worker, which is quite different from mainthread XHR (and way likelier to be buggy).

That said, I tried XHR in a worker with an empty string as input and responseType set to "json" and did not hit the assert from comment 0...  Same thing with the string "null" as input.
Sure I'll try to bisect, but it'll be a while until I get there. Thanks for pointing out the XHR worker as well. Can you try your test case and see what happens if you just return null, not as a string but just the null type or undefined type.

Thanks!
There is no "null type"...  What goes into XHR from the HTTP layer are strings.  Which is why I'd like to know exactly what string your web server is actually producing in this case.
I'll provide a mochitest case.
Flags: needinfo?(bugmail)
Component: DOM → DOM: Core & HTML
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.