Closed Bug 1067942 Opened 10 years ago Closed 8 years ago

"TypeError: setting a property that has only a getter" without mentioning file and property name

Categories

(Core :: JavaScript Engine, defect)

x86
Windows XP
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla55
Tracking Status
firefox55 --- fixed

People

(Reporter: aceman, Assigned: till)

References

(Blocks 2 open bugs)

Details

(Keywords: dev-doc-complete)

Attachments

(2 files, 1 obsolete file)

I get a ton of warnings in error console in the form "Warning: TypeError: setting a property that has only a getter" but there is no filename and the name of the property. Can that be added so we can debug it properly?
Is this in the browser console? In which build?
It is in the Error console of Thunderbird, current trunk.
Maybe, but I do not see the "(null):0" part and have a "TypeError" there.
(In reply to :aceman from comment #0) > I get a ton of warnings in error console in the form "Warning: TypeError: > setting a property that has only a getter" but there is no filename and the > name of the property. Can that be added so we can debug it properly? +1. I got tons of warnings, too, during the run of mozmill test suite with DEBUG build of TB into the tty console where the testing was invoked. Now, though, please look at the following excerpt. Note that other Javascript warning had filenames and lines, and only the warning in question ended up with no file name and "line 0" moniker. JavaScript strict warning: , line 0: TypeError: setting a property that has only a getter Can it be that the code is inside a code snipet passed to function that interprets it like in "{ java code snippet } " in call backs, etc.? In any case, even in that case, we can know the PROPERTY NAME, right? --- begin excerpt --- ++DOMWINDOW == 5 (0x1eded50) [pid = 26542] [serial = 5] [outer = 0x1cc6870] JavaScript strict warning: resource://jsbridge/modules/server.js, line 216: ReferenceError: reference to undefined property Ci.nsIConverterOutputStream.DEFAULT_REPLACEMENT_CHARACTER JavaScript strict warning: resource://jsbridge/modules/server.js, line 329: ReferenceError: assignment to undeclared variable session JavaScript strict warning: resource://mozmill/modules/utils.js, line 131: TypeError: variable appention redeclares argument JavaScript strict warning: resource://mozmill/modules/utils.js, line 135: SyntaxError: octal literals and octal escape sequences are deprecated JavaScript strict warning: resource://mozmill/modules/utils.js, line 135: SyntaxError: octal literals and octal escape sequences are deprecated JavaScript strict warning: resource://mozmill/modules/utils.js, line 135: SyntaxError: octal literals and octal escape sequences are deprecated JavaScript strict warning: resource://mozmill/modules/utils.js, line 137: SyntaxError: octal literals and octal escape sequences are deprecated JavaScript strict warning: resource://mozmill/modules/utils.js, line 137: SyntaxError: octal literals and octal escape sequences are deprecated JavaScript strict warning: resource://mozmill/modules/utils.js, line 137: SyntaxError: octal literals and octal escape sequences are deprecated JavaScript strict warning: resource://mozmill/modules/utils.js, line 221: SyntaxError: octal literals and octal escape sequences are deprecated JavaScript strict warning: resource://mozmill/modules/utils.js, line 221: SyntaxError: octal literals and octal escape sequences are deprecated JavaScript strict warning: resource://mozmill/modules/utils.js, line 221: SyntaxError: octal literals and octal escape sequences are deprecated JavaScript strict warning: resource://mozmill/modules/utils.js, line 258: SyntaxError: octal literals and octal escape sequences are deprecated JavaScript strict warning: resource://mozmill/modules/utils.js, line 258: SyntaxError: octal literals and octal escape sequences are deprecated JavaScript strict warning: resource://mozmill/modules/utils.js, line 258: SyntaxError: octal literals and octal escape sequences are deprecated JavaScript strict warning: resource://mozmill/modules/elementslib.js, line 261: SyntaxError: test for equality (==) mistyped as assignment (=)? JavaScript strict warning: resource://mozmill/modules/elementslib.js, line 444: TypeError: variable exp redeclares argument JavaScript strict warning: resource://mozmill/stdlib/httpd.js, line 2139: SyntaxError: octal literals and octal escape sequences are deprecated JavaScript strict warning: resource://mozmill/stdlib/httpd.js, line 2139: SyntaxError: octal literals and octal escape sequences are deprecated JavaScript strict warning: resource://mozmill/stdlib/httpd.js, line 2139: SyntaxError: octal literals and octal escape sequences are deprecated JavaScript strict warning: resource://mozmill/stdlib/httpd.js, line 2674: SyntaxError: octal literals and octal escape sequences are deprecated JavaScript strict warning: resource://mozmill/stdlib/httpd.js, line 2674: SyntaxError: octal literals and octal escape sequences are deprecated JavaScript strict warning: resource://mozmill/stdlib/httpd.js, line 2674: SyntaxError: octal literals and octal escape sequences are deprecated JavaScript strict warning: resource://mozmill/stdlib/httpd.js, line 2768: SyntaxError: octal literals and octal escape sequences are deprecated JavaScript strict warning: resource://mozmill/stdlib/httpd.js, line 2768: SyntaxError: octal literals and octal escape sequences are deprecated JavaScript strict warning: resource://mozmill/stdlib/httpd.js, line 2768: SyntaxError: octal literals and octal escape sequences are deprecated JavaScript strict warning: resource://mozmill/stdlib/httpd.js, line 2795: SyntaxError: in strict mode code, functions may be declared only at top level or immediately within another function JavaScript strict warning: resource://mozmill/stdlib/securable-module.js, line 355: ReferenceError: assignment to undeclared variable name JavaScript strict warning: resource://mozmill/modules/frame.js, line 70: ReferenceError: assignment to undeclared variable arrayRemove JavaScript strict warning: resource://mozmill/modules/frame.js, line 76: ReferenceError: assignment to undeclared variable mozmill JavaScript strict warning: resource://mozmill/modules/frame.js, line 76: ReferenceError: assignment to undeclared variable elementslib JavaScript strict warning: resource://mozmill/modules/frame.js, line 76: ReferenceError: assignment to undeclared variable modules JavaScript strict warning: resource://mozmill/modules/frame.js, line 177: ReferenceError: assignment to undeclared variable timers JavaScript strict warning: resource://mozmill/modules/controller.js, line 100: ReferenceError: assignment to undeclared variable waitForEvents JavaScript strict warning: resource://mozmill/modules/controller.js, line 1336: ReferenceError: assignment to undeclared variable controllerAdditions JavaScript strict warning: resource://mozmill/modules/controller.js, line 1341: ReferenceError: assignment to undeclared variable MozMillAsyncTest JavaScript strict warning: resource://mozmill/stdlib/os.js, line 82: ReferenceError: assignment to undeclared variable mPlatform JavaScript strict warning: resource://mozmill/modules/mozmill.js, line 92: ReferenceError: assignment to undeclared variable applicationDictionary JavaScript strict warning: resource://mozmill/modules/mozmill.js, line 190: ReferenceError: assignment to undeclared variable MozMillAsyncTest JavaScript strict warning: resource:///modules/msgDBCacheManager.js, line 131: SyntaxError: in strict mode code, functions may be declared only at top level or immediately within another function JavaScript strict warning: resource://jsbridge/modules/server.js, line 134: ReferenceError: assignment to undeclared variable i JavaScript strict warning: , line 0: TypeError: setting a property that has only a getter JavaScript strict warning: , line 0: TypeError: setting a property that has only a getter JavaScript strict warning: , line 0: TypeError: setting a property that has only a getter JavaScript strict warning: , line 0: TypeError: setting a property that has only a getter JavaScript strict warning: , line 0: TypeError: setting a property that has only a getter JavaScript strict warning: , line 0: TypeError: setting a property that has only a getter JavaScript strict warning: , line 0: TypeError: setting a property that has only a getter ++DOCSHELL 0x28c5000 == 3 [pid = 26542] [id = 3] --- end excerpt ---
Folks, I have more than *3K* lines of warnings in my log and am very keen to remove them if possible. The error message is defined thusly: /mozilla/js/src/js.msg (View Hg log or Hg annotations) line 66 -- MSG_DEF(JSMSG_GETTER_ONLY, 0, JSEXN_TYPEERR, "setting a property that has only a getter") and used in the following locations. /mozilla/dom/bindings/DOMJSProxyHandler.cpp (View Hg log or Hg annotations) line 204 -- JSMSG_GETTER_ONLY); /mozilla/dom/workers/WorkerScope.cpp (View Hg log or Hg annotations) line 380 -- JS_ReportErrorNumber(aCx, js_GetErrorMessage, nullptr, JSMSG_GETTER_ONLY); /mozilla/dom/workers/Workers.h (View Hg log or Hg annotations) line 251 -- // Throws the JSMSG_GETTER_ONLY exception. This shouldn't be used going /mozilla/js/src/js.msg (View Hg log or Hg annotations) line 66 -- MSG_DEF(JSMSG_GETTER_ONLY, 0, JSEXN_TYPEERR, "setting a property that has only a getter") /mozilla/js/src/jsobj.cpp (View Hg log or Hg annotations) line 6177 -- JSMSG_GETTER_ONLY); /mozilla/js/xpconnect/src/XPCQuickStubs.cpp (View Hg log or Hg annotations) line 397 -- JSMSG_GETTER_ONLY); If someone can show how to print the name of the problematic PROPERTY, (at least how to obtain the UTF-8 or ASCII string of the problematic PROPERTY) in typical places where the errors are reported, say, in http://mxr.mozilla.org/comm-central/source/mozilla/dom/bindings/DOMJSProxyHandler.cpp#195 195 bool 196 DOMProxyHandler::defineProperty(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, 197 MutableHandle<JSPropertyDescriptor> desc, bool* defined) const 198 { 199 if (desc.hasGetterObject() && desc.setter() == JS_StrictPropertyStub) { 200 return JS_ReportErrorFlagsAndNumber(cx, 201 JSREPORT_WARNING | JSREPORT_STRICT | 202 JSREPORT_STRICT_MODE_ERROR, 203 js_GetErrorMessage, nullptr, 204 JSMSG_GETTER_ONLY); 205 } or in http://mxr.mozilla.org/comm-central/source/mozilla/js/src/jsobj.cpp#5006 4998 if (!shape->hasSlot()) { 4999 /* 5000 * Allow API consumers to create shared properties with stub setters. 5001 * Such properties effectively function as data descriptors which are 5002 * not writable, so attempting to set such a property should do nothing 5003 * or throw if we're in strict mode. 5004 */ 5005 if (!shape->hasGetterValue() && shape->hasDefaultSetter()) 5006 return js_ReportGetterOnlyAssignment(cx, strict); 5007 } js_ReportGetterOnlyAssignment() is a function that prints the warning. OR in http://mxr.mozilla.org/comm-central/source/mozilla/ 5501 } else if (shape) { 5502 /* ES5 8.12.4 [[Put]] step 2. */ 5503 if (shape->isAccessorDescriptor()) { 5504 if (shape->hasDefaultSetter()) { 5505 /* Bail out of parallel execution if we are strict to throw. */ 5506 if (mode == ParallelExecution) 5507 return !strict; 5508 5509 return js_ReportGetterOnlyAssignment(cxArg->asJSContext(), strict); 5510 }js/src/jsobj.cpp#5501 Then I can print it locally in my test run using (maybe fprintf()) and report back the offending PROPERTY names for people in the know to fix. I hope the surrounding context in the above calls contain enough information for the property NAME, if not, we need to PASS the necessary information in the call chain. I repeat: I have more than *3K* lines of warnings in my log and am very keen to remove them if possible. TIA
I recommend starting by adding printfs to those callsites to see which of them is actually triggering. Once we know that we can figure out how to get the property name in printable form.
(In reply to Boris Zbarsky [:bz] from comment #7) > I recommend starting by adding printfs to those callsites to see which of > them is actually triggering. Once we know that we can figure out how to get > the property name in printable form. Thank you for the hint. Will do.
Hi, I found out that all the warnings are printed in the following code path. 2951 DEBUG: before calling js_ReportGetterOnlyAssignment for getter only message in /REF-COMM-CENTRAL/comm-central/mozilla/js/src/jsobj.cpp at 5514 2951 DEBUG: js_ReportGetterOnlyAssignment printing getter only message in /REF-COMM-CENTRAL/comm-central/mozilla/js/src/jsobj.cpp at 6180 2951 JavaScript strict warning: , line 0: TypeError: setting a property that has only a getter (I quit a hanging dialog, which usually times out after 10 minutes to continue the rest of the processing, and thus the warning lines are slightly below 3K) http://mxr.mozilla.org/comm-central/source/mozilla/js/src/jsobj.cpp#5497 5497 if (IsImplicitDenseOrTypedArrayElement(shape)) { 5498 /* ES5 8.12.4 [[Put]] step 2, for a dense data property on pobj. */ 5499 if (pobj != obj) 5500 shape = nullptr; 5501 } else if (shape) { 5502 /* ES5 8.12.4 [[Put]] step 2. */ 5503 if (shape->isAccessorDescriptor()) { 5504 if (shape->hasDefaultSetter()) { 5505 /* Bail out of parallel execution if we are strict to throw. */ 5506 if (mode == ParallelExecution) 5507 return !strict; 5508 5509 return js_ReportGetterOnlyAssignment(cxArg->asJSContext(), strict); 5510 } Line 5597 is where the Getter Only Assignment is reported. (But I found it a little strange to see this part is *INSIDE* shape->hasDefaultSetter()) Anyway, if we can know and print the Name of the property that is causing the warning to be printed just before 5509, all is well. (I am afraid within js_ReportGetterOnlyAssignment(), we may not have enough context information ?) TIA
> Line 5597 is where the Getter Only Assignment is reported. I think my fingers slipped on the keyboard. It should read line 5509. (Right, I noticed that 5509 is referred to correctly five lines down below.) (The line numbers in my log is slightly off due to the fprintf() statements in the file.) TIA
Taking this. Looks easy enough to fix and is really annoying.
Assignee: nobody → till
Status: NEW → ASSIGNED
This changes the error message to include the property name and all call sites to actually provide it. As straight-forward as it gets. With one catch in the quickstub usage. I talked about that with bz and Ms2ger on IRC and we agreed that just passing in an empty string should be fine, as this code path is almost or entirely unused. Still, r?Ms2ger for that part. try-servering here: https://treeherder.mozilla.org/ui/#/jobs?repo=try&revision=7252abc3aba8
Attachment #8497185 - Flags: review?(terrence)
Attachment #8497185 - Flags: review?(Ms2ger)
Comment on attachment 8497185 [details] [diff] [review] Change error message for attempted getter-only property writes to include the property name Review of attachment 8497185 [details] [diff] [review]: ----------------------------------------------------------------- r=bz for the XPCQuickStubs.cpp change (http://logs.glob.uno/?c=mozilla%23jsapi&s=29+Sep+2014&e=29+Sep+2014#c483006).
Attachment #8497185 - Flags: review?(Ms2ger) → review+
Hi, With the patch posted here, I found out that, during the |make mozmill| test suite run of DEBUG version of TB, these lines are printed. The first line was printed 3110 times. : "Services" ??? The second line was printed once. I have no idea why it was not printed in the previous test run. But timing-related bugs may mask transient bugs. 3110 JavaScript strict warning: , line 0: TypeError: setting getter-only property "Services" 1 JavaScript strict warning: chrome://messenger/content/specialTabs.js, line 530: TypeError: setting getter-only property "loadingTabString" The second message comes from the following code: http://mxr.mozilla.org/comm-central/source/mail/base/content/specialTabs.js#520 520 /** 521 * A tab to show content pages. 522 */ 523 contentTabType: { 524 __proto__: contentTabBaseType, 525 name: "contentTab", 526 perTabPanel: "vbox", 527 lastBrowserId: 0, 528 get loadingTabString() { 529 delete this.loadingTabString; 530 return this.loadingTabString = document.getElementById("bundle_messenger") 531 .getString("loadingTab"); 532 }, 533 TIA
New version, just fixes some jetpack tests, no other changes.
Attachment #8498075 - Flags: review?(terrence)
Attachment #8497185 - Attachment is obsolete: true
Attachment #8497185 - Flags: review?(terrence)
(In reply to ISHIKAWA, Chiaki from comment #14) > Hi, > > With the patch posted here, I found out that, during the |make mozmill| test > suite run > of DEBUG version of TB, these lines are printed. > The first line was printed 3110 times. : "Services" ??? We can look at this in a new bug to not drive this one off-topic. > 1 JavaScript strict warning: > chrome://messenger/content/specialTabs.js, line 530: TypeError: setting > getter-only property "loadingTabString" > > The second message comes from the following code: > > http://mxr.mozilla.org/comm-central/source/mail/base/content/specialTabs. > js#520 > > 520 /** > 521 * A tab to show content pages. > 522 */ > 523 contentTabType: { > 524 __proto__: contentTabBaseType, > 525 name: "contentTab", > 526 perTabPanel: "vbox", > 527 lastBrowserId: 0, > 528 get loadingTabString() { > 529 delete this.loadingTabString; > 530 return this.loadingTabString = > document.getElementById("bundle_messenger") > 531 .getString("loadingTab"); > 532 }, > 533 This one is weird as this pattern is used very often in other files too. But we should take also this one to a new bug. Make both bugs block your bug 826732.
Attachment #8498075 - Flags: review?(terrence) → review+
So this was backed out. Till, can you revise the patch please?
Flags: needinfo?(till)
Blocks: 1134253
I just hit this with seamonkey-2.33.1: --DOCSHELL 0x7fe4a3287300 == 7 [pid = 6567] [id = 7] --DOCSHELL 0x7fe4a328f000 == 6 [pid = 6567] [id = 9] --DOCSHELL 0x7fe4a328cd00 == 5 [pid = 6567] [id = 8] --DOMWINDOW == 19 (0x7fe4bf757800) [pid = 6567] [serial = 2] [outer = (nil)] [url = about:blank] --DOMWINDOW == 18 (0x7fe4a0893400) [pid = 6567] [serial = 20] [outer = (nil)] [url = chrome://global/content/commonDialog.xul] --DOMWINDOW == 17 (0x7fe4a088e800) [pid = 6567] [serial = 18] [outer = (nil)] [url = chrome://global/content/commonDialog.xul] --DOMWINDOW == 16 (0x7fe4a3d36000) [pid = 6567] [serial = 14] [outer = (nil)] [url = chrome://global/content/commonDialog.xul] --DOMWINDOW == 15 (0x7fe4a089d800) [pid = 6567] [serial = 16] [outer = (nil)] [url = chrome://global/content/commonDialog.xul] ++DOCSHELL 0x7fe4a3288200 == 6 [pid = 6567] [id = 10] ++DOMWINDOW == 16 (0x7fe4a0895400) [pid = 6567] [serial = 22] [outer = (nil)] ++DOMWINDOW == 17 (0x7fe4a0895800) [pid = 6567] [serial = 23] [outer = 0x7fe4a0895400] JavaScript strict warning: , line 0: TypeError: setting a property that has only a getter ++DOCSHELL 0x7fe4a9bbd600 == 7 [pid = 6567] [id = 11] ++DOMWINDOW == 18 (0x7fe4a0897c00) [pid = 6567] [serial = 24] [outer = (nil)] ++DOCSHELL 0x7fe4af7d4700 == 8 [pid = 6567] [id = 12] ++DOMWINDOW == 19 (0x7fe4a3d10480) [pid = 6567] [serial = 25] [outer = (nil)] ++DOCSHELL 0x7fe4b7a2c500 == 9 [pid = 6567] [id = 13] ++DOMWINDOW == 20 (0x7fe4a3d29400) [pid = 6567] [serial = 26] [outer = (nil)] ++DOCSHELL 0x7fe4b8296b00 == 10 [pid = 6567] [id = 14] ++DOMWINDOW == 21 (0x7fe4b8359a80) [pid = 6567] [serial = 27] [outer = (nil)] ++DOMWINDOW == 22 (0x7fe4b835d280) [pid = 6567] [serial = 28] [outer = 0x7fe4b8359a80]
(In reply to Martin Mokrejs from comment #20) > I just hit this with seamonkey-2.33.1: > Strange, I have not seen these errors for the last couple of months (or longer) with DEBUG build of TB. |make mozmill| test run finishes without printing the cryptic message line: JavaScript strict warning: , line 0: TypeError: setting a property that has only a getter Of course, there are OTHER TypeError errors but with names printed properly, e.g., 2 JavaScript error: chrome://global/content/bindings/notification.xml, line 462: TypeError: this.close is not a function 1 JavaScript error: chrome://messenger/content/chat/imStatusSelector.js, line 36: TypeError: document.getElementById(...) is null 6 JavaScript error: chrome://messenger/content/cloudfile/addAccountDialog.js, line 122: TypeError: this._settings.contentDocument.body is undefined 8 JavaScript error: chrome://messenger/content/cloudfile/addAccountDialog.js, line 205: TypeError: this._accountType is null 5 JavaScript error: chrome://messenger/content/folderDisplay.js, line 1125: TypeError: this.view.displayedFolder is null 11 JavaScript error: chrome://messenger/content/folderDisplay.js, line 2479: TypeError: this.view.dbView is null 4 JavaScript error: chrome://messenger/content/folderPane.js, line 2109: TypeError: null has no properties 4 JavaScript error: chrome://messenger/content/mailContextMenus.js, line 50: TypeError: gContextMenu is null 1 JavaScript error: chrome://messenger/content/messageWindow.js, line 253: TypeError: this.folderDisplay.view.dbView is null 1 JavaScript error: chrome://messenger/content/messengercompose/MsgComposeCommands.js, line 3327: TypeError: gMsgCompose is null 4 JavaScript error: chrome://messenger/content/nsContextMenu.js, line 424: TypeError: aNode is null A few of them are new and appeared in the last couple of months :-(
(In reply to :aceman from comment #19) > So this was backed out. Till, can you revise the patch please? Care to check on try if this still busts tests?
[Learn more] page for this error, https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Getter_only According to some telemetry probes, this error appears quite frequently in the wild. As you can see on the MDN page, Chrome is way more helpful here ("TypeError: Cannot set property "prop" of #<Object> which has only a getter.")
Blocks: jserror
Keywords: dev-doc-needed
Pushed by bzbarsky@mozilla.com: https://hg.mozilla.org/integration/mozilla-inbound/rev/9377eb0e4de3 Change error message for attempted getter-only property writes to include the property name. r=terrence,ms2ger
Try at https://treeherder.mozilla.org/#/jobs?repo=try&revision=dd05ab467c04ffe30449c84eada7c4a829e3ff29 looked reasonable. I fixed the devtools/client/webconsole/test/browser_webconsole_strict_mode_errors.js failure.
Status: ASSIGNED → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla55
Flags: needinfo?(till)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: