Closed
Bug 1073338
Opened 10 years ago
Closed 10 years ago
"Too much recursion" error when using Pseudolocale
Categories
(Firefox OS Graveyard :: Gaia::L10n, defect)
Tracking
(Not tracked)
RESOLVED
FIXED
People
(Reporter: zbraniecki, Assigned: stas)
Details
Attachments
(1 file, 1 obsolete file)
(deleted),
patch
|
zbraniecki
:
review+
|
Details | Diff | Splinter Review |
STR:
- switch language to Pseudolocale
- dial
- end the call
Current result:
E/Usage (22472): [JavaScript Error: "too much recursion" {file: "app://costcontrol.gaiamobile.org/gaia_build_message_handler.js" line: 128}]
Assignee | ||
Comment 2•10 years ago
|
||
I'm able to reproduce and I'm currently investigating. It looks like the error is happening in walkContent here:
https://github.com/mozilla-b2g/gaia/blob/19d33962bdab24acadc22d3e3d07a8ec0bed5fe9/shared/js/l10n.js#L921
which is why you see it for pseudolocales. walkContent is used to walk the en-US AST and pseudolocalize it.
Assignee: nobody → stas
Flags: needinfo?(stas)
Assignee | ||
Comment 3•10 years ago
|
||
This is caused by the notorious Object.prototype.extend in the Usage app.
https://github.com/mozilla-b2g/gaia/blob/master/apps/costcontrol/js/utils/toolkit.js#L34
I'll have a fix in a minute.
Assignee | ||
Comment 4•10 years ago
|
||
Pull request: https://github.com/mozilla-b2g/gaia/pull/24485
TBPL: https://tbpl.mozilla.org/?rev=2253bb27664c&tree=Gaia-Try
Even if we use Object.create(null) to create new ASTs, if we take it from JSON, its objects will use Object.prototype. So we need this additional check here.
Attachment #8496107 -
Flags: review?(gandalf)
Reporter | ||
Updated•10 years ago
|
Attachment #8496107 -
Flags: review?(gandalf) → review+
Assignee | ||
Comment 5•10 years ago
|
||
(In reply to Staś Małolepszy :stas from comment #3)
> This is caused by the notorious Object.prototype.extend in the Usage app.
>
> https://github.com/mozilla-b2g/gaia/blob/master/apps/costcontrol/js/utils/
> toolkit.js#L34
I filed bug 1073608 for this.
Assignee | ||
Comment 6•10 years ago
|
||
https://github.com/mozilla-b2g/gaia/pull/24485
https://tbpl.mozilla.org/?rev=f132b7d624f1&tree=Gaia-Try
The previous patch was wrong: for objects created with Object.create(null) we can't use obj.hasOwnProperty. Here's another approach that we employ elsewhere: use Object.keys and iterate over the object's own keys.
The only trouble with this is that Object.keys throws if called on a non-object. I've added a check for falsyness, but it doesn't protect us against numbers. OTOH, we don't accept numbers as values in our AST, so we should never run into this problem.
Gandalf, what do you think about this? Should this be more defensive, or is it okay as-is?
Attachment #8496107 -
Attachment is obsolete: true
Attachment #8498068 -
Flags: review?(gandalf)
Reporter | ||
Comment 7•10 years ago
|
||
Comment on attachment 8498068 [details] [diff] [review]
Object.keys
Review of attachment 8498068 [details] [diff] [review]:
-----------------------------------------------------------------
::: shared/js/l10n.js
@@ +912,5 @@
> /* Utility functions */
>
> // Recursively walk an AST node searching for content leaves
> function walkContent(node, fn) {
> + if (!node || typeof node === 'string') {
In which scenario the node is falsy and yet you want to return fn(node) for it?
Assignee | ||
Comment 8•10 years ago
|
||
I was thinking about entities with null values, but I now realize that the AST simply won't contain the 'value' property at all in these cases. I'll remove that check.
Assignee | ||
Comment 9•10 years ago
|
||
New PR: https://github.com/mozilla-b2g/gaia/pull/24835 (the previous one was closed during the Great Closing of PRs).
Reporter | ||
Comment 10•10 years ago
|
||
Comment on attachment 8498068 [details] [diff] [review]
Object.keys
Review of attachment 8498068 [details] [diff] [review]:
-----------------------------------------------------------------
::: shared/js/l10n.js
@@ +912,5 @@
> /* Utility functions */
>
> // Recursively walk an AST node searching for content leaves
> function walkContent(node, fn) {
> + if (!node || typeof node === 'string') {
in which condition you want to return fn(node) when node is falsy?
Attachment #8498068 -
Flags: review?(gandalf) → review+
Assignee | ||
Comment 11•10 years ago
|
||
Master: https://github.com/mozilla-b2g/gaia/commit/df5a4d52c707be9afeee109006f4ea0391e755f6
L20n: https://github.com/l20n/l20n.js/commit/903a7c2b03e83ec5858979e9354a951df08e8fff
Status: NEW → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•