Jump to content

Wikipedia:Reporting JavaScript errors: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
don't forget OSX! :)
No edit summary
 
(35 intermediate revisions by 18 users not shown)
Line 1: Line 1:
{{shortcut|WP:JSERROR}}
<noinclude>{{Wikipedia how to|WP:RJE|WP:JSERROR}}</noinclude>

== Info to include in bug reports ==
When you experience an error with [[WP:gadgets|gadgets]] or [[WP:User scripts|user scripts]] and you want to report the issue at the appropriate page, please include the following information:
When you experience an error with [[WP:gadgets|gadgets]] or [[WP:User scripts|user scripts]] and you want to report the issue at the appropriate page, please include the following information:
# What is the behaviour you're seeing?
# What is the behaviour you're seeing?
Line 5: Line 7:
# How can the incorrect behaviour be reproduced? Describe ''exactly'' what you're doing and seeing.
# How can the incorrect behaviour be reproduced? Describe ''exactly'' what you're doing and seeing.
# Confirm that you have tried [[Wikipedia:Bypass your cache|bypassing your browser cache]].
# Confirm that you have tried [[Wikipedia:Bypass your cache|bypassing your browser cache]].
# Make note of your browser, browser version, operating system, and operating system version.
# Make note of the skin that you use, your browser, browser version, and operating system.
# Append relevant JavaScript errors your browser logged. To do that, open your JavaScript console or error console, and copy the relevant error messages. Where you find your JavaScript console depends on your browser:
# Mention relevant JavaScript errors your browser logged. To do that, open your JavaScript console, and copy the relevant error messages. Error messages usually appear in red.
⚫
You are urged to have a look at [http://www.chiark.greenend.org.uk/~sgtatham/bugs.html "How to Report Bugs Effectively"] by [[Simon Tatham]] for hints on how to report bugs effectively, to make sure the issue you are describing can be resolved as promptly as possible.
#* Internet Explorer: Press {{Key press|F12}}; refresh the Wikipedia page; JavaScript errors appear on the "Console" tab of the F12 tools.

#* Firefox: Press {{Key press|F12}} or for OSX, use {{Key press|Option|Command|I}}; JavaScript errors appear on the "Console" tab of the F12 tools. Make sure "Net", "JS", "Security" and "Logging" are turned on (blue).
== How to open your JavaScript console ==
⚫
#* Opera: Page menu → Developer Tools → Error Console.
{{Shortcut|WP:CONSOLEERROR|Help:CONSOLE}}
⚫
#* Chrome: Page menu → Tools → JavaScript Console ({{Key press|Ctrl|Shift|J}}). For OSX, use {{Key press|Option|Command|I}} then hit {{key press|esc}} (escape) to open the JavaScript console. Errors will appear in red.
Where to find your JavaScript console depends on your browser:
#* Safari: Develop menu → Show Error Console ({{Key press|Ctrl|Alt|C}} or {{Key press|Alt|Cmd|C}}). You might have to enable the Develop menu first in Preferences → Advanced. For OSX, use {{Key press|Option|Command|I}} then hit {{key press|esc}} (escape) to open the JavaScript console. Errors will appear in red.
{| class="wikitable"
|+ How to open the console
|-
!Computer
! Browser !! Windows/Linux !! Mac
|-
| rowspan="5" |Desktop/Laptop
| [[Google Chrome|Chrome]]/[[Chromium (web browser)|Chromium]]<br />[[Microsoft Edge|Edge]] (version 79+)<br />[[Opera (web browser)|Opera]] (version 15+) || {{Key press|Ctrl|Shift|J}} || {{Key press|Option|Command|J}}
|-
| [[Firefox]] || {{Key press|F12}} || {{Key press|Option|Command|K}}
|-
| [[Safari (web browser)|Safari]] || {{Key press|Ctrl|Alt|C}} || {{Key press|Option|Cmd|C}}*
|-
| [[Internet Explorer]]<br />[[Microsoft Edge|Edge]] (up to version 78) || {{Key press|F12}} → Console || –
|-
⚫
| [[Opera (web browser)|Opera]] (up to version 14) || Page menu → Developer Tools → Error Console
|
|-
|Tablet/Mobile
| colspan="3" |Mobile operating systems do not usually have developer tools or consoles. However, some mobile browsers support remote debugging, where you connect your mobile device to a desktop via USB, and then you can access developer tools/consoles that way. [https://firefox-source-docs.mozilla.org/devtools-user/about_colon_debugging/index.html Firefox USB debugging]. [https://developer.chrome.com/docs/devtools/remote-debugging/ Chrome USB debugging].
|}
On some browsers, you may have to click on the "Console" tab once the developer tools pane opens up.

⚫
[*] In Safari, you might have to enable the Develop menu first in Preferences ({{keys|Cmd|,}}) → Advanced → check "Show develop menu in menu bar". For OSX, use {{Key press|Option|Command|I}} then hit {{key press|esc}} (escape) to open the JavaScript console. Errors will appear in red.

=== Once you've opened the console... ===
[[File:Screenshot_of_Chrome_DevTools_console_tab.png|thumb|Google Chrome DevTools, Console tab]]
[[File:Chromium_DevTools_screenshot_of_triangle.png|thumb|The "triangle" can be clicked to reveal some hidden info.]]

# Click on the "Console" tab
# Scroll to the bottom of the console and look for log entries in yellow and red. Copy or screenshot these.
# If there is a "triangle" you can press to expand and show more info, do so, and copy/screenshot that info too.<ref>This extra info will show the [[stack trace]], which is needed to figure out which user script and what line #.</ref>

=== Which one is the error? ===
Unfortunately there is a lot of junk in the console. Programmers really only need one error message to debug, but the trick is getting the right error message. Here's some examples of useful error messages:

* Uncaught – typically red
** Uncaught DOMException
** Uncaught Error
** Uncaught ReferenceError
** Uncaught SyntaxError
** Uncaught TypeError
** Uncaught (something in all lowercase)<ref>[[mw:API:Main page|MediaWiki API]] error</ref>
* jQuery exception – typically yellow
** jQuery.Deferred exception


==See also==
⚫
You are urged to have a look at http://www.chiark.greenend.org.uk/~sgtatham/bugs.html for hints on how to report bugs effectively, to make sure the issue you are describing can be resolved as promptly as possible.
*[[mw:Help:Locating broken scripts]]


== Notes ==
[[Category:Wikipedia scripts]]
[[Category:Wikipedia scripts| Reporting JavaScript errors]]
[[Category:Wikipedia how-to|JavaScript errors]]

Latest revision as of 05:42, 6 October 2025

Info to include in bug reports

[edit source]

When you experience an error with gadgets or user scripts and you want to report the issue at the appropriate page, please include the following information:

  1. What is the behaviour you're seeing?
  2. What is the behaviour you're expecting to see?
  3. How can the incorrect behaviour be reproduced? Describe exactly what you're doing and seeing.
  4. Confirm that you have tried bypassing your browser cache.
  5. Make note of the skin that you use, your browser, browser version, and operating system.
  6. Mention relevant JavaScript errors your browser logged. To do that, open your JavaScript console, and copy the relevant error messages. Error messages usually appear in red.

You are urged to have a look at "How to Report Bugs Effectively" by Simon Tatham for hints on how to report bugs effectively, to make sure the issue you are describing can be resolved as promptly as possible.

How to open your JavaScript console

[edit source]

Where to find your JavaScript console depends on your browser:

How to open the console
Computer BrowserWindows/LinuxMac
Desktop/Laptop Chrome/Chromium
Edge (version 79+)
Opera (version 15+)
Ctrl+⇧ Shift+J⌥ Option+⌘ Command+J
FirefoxF12⌥ Option+⌘ Command+K
SafariCtrl+Alt+C⌥ Option+⌘ Cmd+C*
Internet Explorer
Edge (up to version 78)
F12 → Console–
Opera (up to version 14)Page menu → Developer Tools → Error Console
Tablet/Mobile Mobile operating systems do not usually have developer tools or consoles. However, some mobile browsers support remote debugging, where you connect your mobile device to a desktop via USB, and then you can access developer tools/consoles that way. Firefox USB debugging. Chrome USB debugging.

On some browsers, you may have to click on the "Console" tab once the developer tools pane opens up.

[*] In Safari, you might have to enable the Develop menu first in Preferences (⌘ Cmd+,) → Advanced → check "Show develop menu in menu bar". For OSX, use ⌥ Option+⌘ Command+I then hit esc (escape) to open the JavaScript console. Errors will appear in red.

Once you've opened the console...

[edit source]
Google Chrome DevTools, Console tab
The "triangle" can be clicked to reveal some hidden info.
  1. Click on the "Console" tab
  2. Scroll to the bottom of the console and look for log entries in yellow and red. Copy or screenshot these.
  3. If there is a "triangle" you can press to expand and show more info, do so, and copy/screenshot that info too.[1]

Which one is the error?

[edit source]

Unfortunately there is a lot of junk in the console. Programmers really only need one error message to debug, but the trick is getting the right error message. Here's some examples of useful error messages:

  • Uncaught – typically red
    • Uncaught DOMException
    • Uncaught Error
    • Uncaught ReferenceError
    • Uncaught SyntaxError
    • Uncaught TypeError
    • Uncaught (something in all lowercase)[2]
  • jQuery exception – typically yellow
    • jQuery.Deferred exception

See also

[edit source]
  1. ↑ This extra info will show the stack trace, which is needed to figure out which user script and what line #.
  2. ↑ MediaWiki API error