Etherpad-lite: Uncaught TypeError: Cannot read property 'setStateIdle' of null

Created on 28 May 2018  路  34Comments  路  Source: ether/etherpad-lite

I'm getting the following error in Chrome 66 when accessing a pad in our instance (running 1.6.6).
Meanwhile, access with Firefox 60 works without problems. Any tips?

An error occurred
The error was reported with the following id: 'qZF4pJdMtrdhNgDJlfp0'

Please press and hold Ctrl and press F5 to reload this page, if the problem persists please send this error message to your webmaster:
'ErrorId: qZF4pJdMtrdhNgDJlfp0
URL: https://pad.example.com/padname
UserAgent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Safari/537.36
Uncaught TypeError: Cannot read property 'setStateIdle' of null in https://pad.example.com/javascripts/lib/ep_etherpad-lite/static/js/pad.js?callback=require.define at line 3'

It seems to stem from this code section, where pad.collabClient seems to be null:

            socket.on("error", function(e) {
                pad.collabClient.setStateIdle(),
                pad.collabClient.setIsPendingRevision(!0)
            });

When pausing with a breakpoint, the error e is undefined.

According to the call stack, the error occurred in this call:

            io.connect(n, {
                path: exports.baseURL + "socket.io",
                resource: a,
                reconnectionAttempts: 5,
                reconnection: !0,
                reconnectionDelay: 1e3,
                reconnectionDelayMax: 5e3
            })

P.S.: It's actually suprising that pad.collabClient is already used in the handshake(), while it is only initialized in _afterHandshake().

P.P.S.: Troubleshooting information as follows:

Etherpad version

Version number: 1.6.6

Git sha: 7e69a82
Installed plugins

ep_etherpad-lite

Installed parts

ep_etherpad-lite/swagger
ep_etherpad-lite/adminsettings
ep_etherpad-lite/adminplugins
ep_etherpad-lite/admin
ep_etherpad-lite/tests
ep_etherpad-lite/socketio
ep_etherpad-lite/errorhandling
ep_etherpad-lite/importexport
ep_etherpad-lite/apicalls
ep_etherpad-lite/webaccess
ep_etherpad-lite/padreadonly
ep_etherpad-lite/padurlsanitize
ep_etherpad-lite/specialpages
ep_etherpad-lite/i18n
ep_etherpad-lite/static
ep_etherpad-lite/express

Installed hooks
Server side hooks

expressCreateServer
    ep_etherpad-lite/node/hooks/express/swagger:expressCreateServer from ep_etherpad-lite/swagger
expressCreateServer
    ep_etherpad-lite/node/hooks/express/adminsettings:expressCreateServer from ep_etherpad-lite/adminsettings
expressCreateServer
    ep_etherpad-lite/node/hooks/express/adminplugins:expressCreateServer from ep_etherpad-lite/adminplugins
expressCreateServer
    ep_etherpad-lite/node/hooks/express/admin:expressCreateServer from ep_etherpad-lite/admin
expressCreateServer
    ep_etherpad-lite/node/hooks/express/tests:expressCreateServer from ep_etherpad-lite/tests
expressCreateServer
    ep_etherpad-lite/node/hooks/express/socketio:expressCreateServer from ep_etherpad-lite/socketio
expressCreateServer
    ep_etherpad-lite/node/hooks/express/errorhandling:expressCreateServer from ep_etherpad-lite/errorhandling
expressCreateServer
    ep_etherpad-lite/node/hooks/express/importexport:expressCreateServer from ep_etherpad-lite/importexport
expressCreateServer
    ep_etherpad-lite/node/hooks/express/apicalls:expressCreateServer from ep_etherpad-lite/apicalls
expressCreateServer
    ep_etherpad-lite/node/hooks/express/padreadonly:expressCreateServer from ep_etherpad-lite/padreadonly
expressCreateServer
    ep_etherpad-lite/node/hooks/express/padurlsanitize:expressCreateServer from ep_etherpad-lite/padurlsanitize
expressCreateServer
    ep_etherpad-lite/node/hooks/express/specialpages:expressCreateServer from ep_etherpad-lite/specialpages
expressCreateServer
    ep_etherpad-lite/node/hooks/i18n:expressCreateServer from ep_etherpad-lite/i18n
expressCreateServer
    ep_etherpad-lite/node/hooks/express/static:expressCreateServer from ep_etherpad-lite/static
socketio
    ep_etherpad-lite/node/hooks/express/adminsettings:socketio from ep_etherpad-lite/adminsettings
socketio
    ep_etherpad-lite/node/hooks/express/adminplugins:socketio from ep_etherpad-lite/adminplugins
expressConfigure
    ep_etherpad-lite/node/hooks/express/webaccess:expressConfigure from ep_etherpad-lite/webaccess
createServer
    ep_etherpad-lite/node/hooks/express:createServer from ep_etherpad-lite/express
restartServer
    ep_etherpad-lite/node/hooks/express:restartServer from ep_etherpad-lite/express

Client side hooks
Bug Needs confirmation

Most helpful comment

Good news, @fralix.
Good documentation is precious.

I leave the issue open, since I continue being curious about the "phantom" initialization uncovered by @caugner.

I am starting to think about how to improve the codebase without rewriting it (more tests, linters, static analyzers, maybe even gradually migrating to TypeScript...), and this sort of issues interest me a lot.

All 34 comments

Related?
TypeError: pad.collabClient is null in https://pad.fralix.ovh/javascripts/lib/ep_etherpad-lite/static/js/pad.js?callback=require.define at line 3'
This is shown for to me instead of the Uncaught line. This problem persisted for me for years (!) with default installation, i just had another try with a fresh install, but still experience the same problem using Firefox (Nightly)

P.S.: It's actually suprising that pad.collabClient is already used in the handshake(), while it is only initialized in _afterHandshake().

Indeed it is, @caugner.
I am not being able to trigger the bug (current develop, Firefox 61, Chromium 68), but the hairy initialization is a potential problem on its own. Fixing that could probably give us a clue about this issue, or solve it altogether.

@anugu-chegg, since you worked closely on this file for #3318, do you have some hints?

Hey, I can no longer reproduce the issue with a proper proxy setup:

https://github.com/ether/etherpad-lite/wiki/How-to-put-Etherpad-Lite-behind-a-reverse-Proxy
https://github.com/ether/etherpad-lite/issues/2318#issuecomment-63548542

So i guess the issue is really down to the socket connection and reading all the guides may help? :joy:

Good news, @fralix.
Good documentation is precious.

I leave the issue open, since I continue being curious about the "phantom" initialization uncovered by @caugner.

I am starting to think about how to improve the codebase without rewriting it (more tests, linters, static analyzers, maybe even gradually migrating to TypeScript...), and this sort of issues interest me a lot.

Hi there,
thanks for creating etherpad. I am using it in a project for Fridays For Future Germany.
This bug also occurred in our installation, version 1.7.5:

Uncaught TypeError: Cannot read property 'setStateIdle' of null in https://domain.removed.also.the.path/static/js/pad.js?callback=require.define at line 3'

We have this plugins installed:

ep_etherpad-lite
ep_headings2
ep_font_color
ep_footer

Just wanted to report it!
Let me know if I can provide more information to fix this issue.

I can confirm that this error is also present in v1.8.0.

Dec 12 10:59:51 etherpad nodejs[28467]: #033[33m[2019-12-12 10:59:51.645] [WARN] client - #033[39mUncaught TypeError: Cannot read property 'setStateIdle' of null -- { errorId: 'ZFFGAJRhNPLZkgcdXRxQ',
Dec 12 10:59:51 etherpad nodejs[28467]:    'Uncaught TypeError: Cannot read property \'setStateIdle\' of null',

I am using etherpad_lite version 1.6.0 version. we have also observed this issue like that

App 19183 output: [2020-03-26 09:29:22.650] [WARN] client - Uncaught TypeError: Cannot read property 'setStateIdle' of null -- { errorId: '3tl0hHxTQ9rwZ0ojNXoI',
App 19183 output:   msg:
App 19183 output:    'Uncaught TypeError: Cannot read property \'setStateIdle\' of null',
App 19183 output:   url:
App 19183 output:    'https://etherpad.vnc.biz/etherpad/p/g.INJVOHVXSaiTwtQM$0c6efa006f3911ea8c106f96aa173764',
App 19183 output:   linenumber: 3,
App 19183 output:   userAgent:
App 19183 output:    'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/80.0.3987.87 Chrome/80.0.3987.87 Safari/537.36' }

Any one can find out the solution for this issue ?

and I know that issue related to socket connection but not find out the exact root cause for this issue why getting socket on error ?

@vijaygodhasara Please don't use Etherpad 1.6. Please update and let us know if it persists.

@xshadow Please provide some information such as:

  • Is your Etherpad on windows/linux
  • Exact Git Rev
  • Is your Etherpad running behind a reverse proxy? If so, what?
  • Are you running any plugins?

FWIW I am not seeing this bug at all across any of our instances so I think it's a configuration issue or something that isn't related to Core.

Please look at https://github.com/ether/etherpad-lite/issues/3405#issuecomment-413032184 - After a successful proxy setup this issue disappeared for me. I saw it again when there was an unstable network connection, so it's probably down to some issues with something not correctly accessible, but mainly a setup / network issue.

I think this bug can be closed when current reporters don't reply and if someone experiences it again, they should provide more details about the configuration and check if it's a problem with their network connection ... Also, it's very helpful to open the browser debug console and check for network connections. Especially some wrongly setup CSPs can prevent resources from loading. I just had this with another project.

Closing, will re-open if someone experiences moving forward.

If someone experiences problems while setting up an instance (when there is no sensitive user data) it might be interesting to have a look at the system and start debugging from there. I guess I could afford the time to check if it's a general issue with the system configuration, but I'm no NodeJS / etherpad developer, so I won't be able to continue debugging if it appears to be indeed an etherpad bug.

@JohnMcLear After a review of the Proxy settings I can confirm that fix mentioned in the comments above did the trick.

This error is reproduced on different instances of the etherpads in the android and chrome.
Tested on my own server and on https://etherpad.wikimedia.org, https://video.etherpad.com.

An error occurred
Please press and hold Ctrl and press F5 to reload this page
If the problem persists please send this error message to your webmaster:

ErrorId: XDmLq2ENraoB3lM4ESfu
URL: https://etherpad.wikimedia.org/p/gxz0C7Rncg-J80ra7DQw
UserAgent: Mozilla/5.0 (Linux; Android 10; Mi A2 Lite) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.106 Mobile Safari/537.36
Uncaught TypeError: Cannot read property 'setStateIdle' of null聽in https://etherpad.wikimedia.org/javascripts/lib/ep_etherpad-lite/static/js/pad.js?callback=require.define&v=f2b033c9 at line 3

Steps to reproduce

  1. in chrome browser open a new pad
  2. write something
  3. then click on "home" in the android
  4. then through the "last applications" close everything
  5. and run chrome browser again
  6. it will start to open your last pad and give this error

then through the "last applications" close everything
I don't see any "last applications" on my screen.. Where should I be looking?

Oh.. Android... Sec.

Confirmed error! Well done for replicating. You get a cookie good sir! :)

Cannot replicate locally on latest develop. So this is fun :)

Can replicate on video.etherpad.com:9001 (which afaik is direct to Etherpad).

So to narrow it down it's possibly related to:

  1. A plugin.
  2. SSL certs.
  3. Running in production mode.
  4. "slower" than local connectivity/race condition?

Firefox (the good browser) errors with pad.collabClient in the same test.

What are mobile browsers doing different to normal browsers?

It appears it's fixed in latest develop already..

I pulled latest onto https://video.etherpad.com

Can you still replicate?

Etherpad moves quite quick so it's possible this was an edge case in the version prior to me pulling. video.etherpad.com often is a few weeks behind develop because I'm too busy to keep her updated ;/

From https://github.com/ether/etherpad-lite
   2cd3dccc..75ecb3f4  develop                             -> origin/develop

Hi @JohnMcLear! Congratulations, the error cannot be reproduced on https://video.etherpad.com.
Thank you for your work!

It's still there. I can replicate after looking at the code, but I am not sure how this is connected to closing&reopening the tab in android. In pad.js' handshake function, callbacks for socket events are registered that use collabClient. However, collabClient is null until it is set in _afterHandshake right after CLIENT_VARS are received.
So to replicate in firefox/chromium on a desktop:
Load a pad with developer mode open and as soon as you see XHR-Polling to eio cut off network. Be sure that you did not receive the CLIENT_VARS. Then wait a few seconds for the reconnecting phase to start.

So the next question is why did updating and restarting video.etherpad.com fix??!

A bisect showed 128f3e15ebf89f69d97dce34c8d5b8c238e952d2 as the fix-commit. That kind of makes sense.

Next level pro developer fixes bugs before they manifest....

I think there was some issue in jquery or the way we use it, that was easily triggerable and is now resolved with 128f3e15ebf89f69d97dce34c8d5b8c238e952d2
The bug when a reconnect happens (e.g. because of client's bad network) before CLIENT_VARS is received, is still there.
On my instance I see above stacktrace ~1 time a day. Not sure if there is a third way to trigger it or if every occurence on my instance is due to bad network.

@vijaygodhasara Please don't use Etherpad 1.6. Please update and let us know if it persists.

I'm using 1.8.6 and I still got the error!

@cdruet can you provide any details? Did you test without plugins?

@JohnMcLear I have the same problem with 1.8.6 (master branch)

Here is an example: https://mrtopf.de/test.html

loading this pad: https://yopad.eu/p/textframe

Installed plugins are comments_page and headings2.

I hopefully have time later to test it on fresh install without plugins (as I don't necessarily want to disable them on production)

@JohnMcLear I'm also using comments_page. On top of that auth_session.

I can test later today without comments_page but I'm auth_session to reach the pads.

Sent with Unibox

@cdruet and @mrtopf: Can you try the latest commit on the develop branch and set the cookie.sameSite setting to None? There have been some cookie changes since v1.8.6 that might be relevant.

@rhansen can this be closed now?

@rhansen sorry, was a bit busy and setting up a test server took a bit. But I tested develop and this seems to work. So I am waiting for the next release then. Thanks!

I got this error with 1.8.5 & the current master version (based on 1.8.6 = commit 2c8769a6fd9fa4ed36ed6e32ba0826037795fb37)

when updating to develop, the first tests seems to be fine.

when is the next release expected?

Setting: include etherpad via iframe in a server running on localhost.

Stack trace (from the master version, 1.8.6++ as mentioned above), in case this is still relevant:

聽 | (anonymous) | @ | pad.js?callback=requ鈥ine&v=564a4939:227
-- | -- | -- | --
聽 | r.emit | @ | index.js:83
聽 | r.emit | @ | index.js:83
聽 | r.emitAll | @ | index.js:83
聽 | (anonymous) | @ | index.js:83
聽 | setTimeout (async) | 聽 | 聽
聽 | r.reconnect | @ | index.js:83
聽 | r.onclose | @ | index.js:83
聽 | (anonymous) | @ | index.js:83
聽 | r.emit | @ | index.js:83
聽 | r.onClose | @ | index.js:83
聽 | (anonymous) | @ | index.js:83
聽 | setTimeout (async) | 聽 | 聽
聽 | r.onHeartbeat | @ | index.js:83
聽 | (anonymous) | @ | index.js:83
聽 | setTimeout (async) | 聽 | 聽
聽 | r.setPing | @ | index.js:83
聽 | r.onHandshake | @ | index.js:83
聽 | r.onPacket | @ | index.js:83
聽 | (anonymous) | @ | index.js:83
聽 | r.emit | @ | index.js:83
聽 | r.onPacket | @ | index.js:83
聽 | n | @ | index.js:83
聽 | e.decodePayload | @ | index.js:83
聽 | r.onData | @ | index.js:83
聽 | (anonymous) | @ | index.js:83
聽 | r.emit | @ | index.js:83
聽 | i.onData | @ | index.js:83
聽 | i.onLoad | @ | index.js:83
聽 | hasXDR.e.onreadystatechange | @ | index.js:83
聽 | XMLHttpRequest.send (async) | 聽 | 聽
聽 | i.create | @ | index.js:83
聽 | i | @ | index.js:83
聽 | o.request | @ | index.js:83
聽 | o.doPoll | @ | index.js:83
聽 | r.poll | @ | index.js:83
聽 | r.doOpen | @ | index.js:83
聽 | r.open | @ | index.js:83
聽 | r.open | @ | index.js:83
聽 | r | @ | index.js:83
聽 | r | @ | index.js:83
聽 | r.open.r.connect | @ | index.js:83
聽 | r | @ | index.js:83
聽 | r | @ | index.js:83
聽 | r | @ | index.js:83
聽 | handshake | @ | pad.js?callback=requ鈥ine&v=564a4939:207
聽 | (anonymous) | @ | pad.js?callback=requ鈥ine&v=564a4939:484
聽 | mightThrow | @ | ace2_common.js?callb鈥ne&v=564a4939:3910
聽 | process | @ | ace2_common.js?callb鈥ne&v=564a4939:3978
聽 | setTimeout (async) | 聽 | 聽
聽 | (anonymous) | @ | ace2_common.js?callb鈥ne&v=564a4939:4016
聽 | fire | @ | ace2_common.js?callb鈥ne&v=564a4939:3645
聽 | add | @ | ace2_common.js?callb鈥ne&v=564a4939:3704
聽 | (anonymous) | @ | ace2_common.js?callb鈥ne&v=564a4939:4036
聽 | Deferred | @ | ace2_common.js?callb鈥ne&v=564a4939:4120
聽 | then | @ | ace2_common.js?callb鈥ne&v=564a4939:4021
聽 | jQuery.fn.ready | @ | ace2_common.js?callb鈥ne&v=564a4939:4198
聽 | init | @ | pad.js?callback=requ鈥ine&v=564a4939:480
聽 | init | @ | pad.js?callback=requ鈥ine&v=564a4939:960
聽 | (anonymous) | @ | test1?lang=de:725
聽 | setTimeout (async) | 聽 | 聽
聽 | callback | @ | ace2_common.js?callb鈥e&v=564a4939:12053
聽 | (anonymous) | @ | ace2_common.js?callb鈥e&v=564a4939:12060
聽 | fire | @ | ace2_common.js?callb鈥ne&v=564a4939:3645
聽 | fireWith | @ | ace2_common.js?callb鈥ne&v=564a4939:3775
聽 | done | @ | ace2_common.js?callb鈥ne&v=564a4939:9466
聽 | (anonymous) | @ | ace2_common.js?callb鈥ne&v=564a4939:9708
聽 | load (async) | 聽 | 聽
聽 | send | @ | ace2_common.js?callb鈥ne&v=564a4939:9727
聽 | ajax | @ | ace2_common.js?callb鈥ne&v=564a4939:9367
聽 | jQuery. | @ | ace2_common.js?callb鈥ne&v=564a4939:9516
聽 | getJSON | @ | ace2_common.js?callb鈥ne&v=564a4939:9497
聽 | exports.update | @ | ace2_common.js?callb鈥e&v=564a4939:12055
聽 | (anonymous) | @ | test1?lang=de:717
聽 | (anonymous) | @ | test1?lang=de:735

when is the next release expected?

Soon. Hopefully this week.

Was this page helpful?
0 / 5 - 0 ratings