Closed Bug 924071 Opened 11 years ago Closed 11 years ago

Resource's source is null when the resource is an empty file

Categories

(L20n :: JS Library, defect, P1)

defect

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: stas, Assigned: stas)

Details

Attachments

(1 file)

This causes the parser to fail badly in:

  function parse(string) {
    _source = string;
    _index = 0; 
    _length = _source.length;  // <== here
    return getLOL();
  }
Michał, does this help?
Attachment #814064 - Flags: review?(m.goleb+mozilla)
That seems better since I now have more readable error messages but I still do have ones:

TranslationError {name: "TranslationError", message: "[pl] NationalLibrary: Not found", entity: "NationalLibrary", supportedLocales: Array[1], locale: "pl"…}
 l20n.js:1135
RuntimeError {name: "RuntimeError", message: "NationalLibrary: Unable to get translation; tried pl", entity: "NationalLibrary", supportedLocales: Array[1], constructor: function…}

It's caused by the fact that Chrome for some reason returns status code 0 on some l20n files, though if I look later at the network tab I see status 200 so it gets delivered finally, but producing these ugly errors before. :/
Yeah, that's my worry about switching our IO to use readyState and reacting to code 0. I'd like to get back to using only 200, but that seems to make a mess for local/emulation cases.
OS: Linux → All
Hardware: x86_64 → All
(In reply to Zbigniew Braniecki [:gandalf] from comment #3)
> Yeah, that's my worry about switching our IO to use readyState and reacting
> to code 0. I'd like to get back to using only 200, but that seems to make a
> mess for local/emulation cases.

What local/emulation cases? Anyway, this needs to be resolved in some way since these errors really flood the console which makes debugging real problems a little harder.
Assignee: nobody → stas
Priority: -- → P1
Target Milestone: --- → 1.0
Weird enough, I stopped seeing this error in Chrome stable. I do see it in Canary, but it might be a fault of this browser so I'm not sure if there's anything that can be done, unfortunately... :/
Comment on attachment 814064 [details] [diff] [review]
Empty text is okay

Review of attachment 814064 [details] [diff] [review]:
-----------------------------------------------------------------

This doesn't necessarily remove all the potential errors but makes them bubble up to be handled on a higher level which makes for more readable error messages.
Attachment #814064 - Flags: review?(m.goleb+mozilla) → review+
I tried to debug this, and came to a conclusion that this patch fixes a different bug.  Hence the change of the bug summary.

For the issue that Michał reported, I think we should file a separate bug and investigate.  I tried Chrome Canary but was unable to reproduce status code 0 for the XHRs.
Summary: Resource's source is null when the resource can't be downloaded → Resource's source is null when the resource is an empty file
Fixed: https://github.com/l20n/l20n.js/commit/7386375977872d63a28c879e41afd56701ed1635
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: