Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncaught TypeError: Cannot read property 'setStateIdle' of null #3405

Closed
caugner opened this issue May 28, 2018 · 34 comments
Closed

Uncaught TypeError: Cannot read property 'setStateIdle' of null #3405

caugner opened this issue May 28, 2018 · 34 comments
Assignees
Milestone

Comments

@caugner
Copy link
Contributor

caugner commented May 28, 2018

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
@fnetX
Copy link

fnetX commented Jun 20, 2018

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)

@muxator muxator added the Bug label Aug 14, 2018
@muxator
Copy link
Contributor

muxator commented Aug 14, 2018

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?

@fnetX
Copy link

fnetX commented Aug 14, 2018

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
#2318 (comment)

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

@muxator
Copy link
Contributor

muxator commented Aug 14, 2018

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.

@uyewshrdjklnf
Copy link

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_adminpads
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.

@xshadow
Copy link

xshadow commented Dec 12, 2019

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',

@vijaygodhasara
Copy link

vijaygodhasara commented Mar 28, 2020

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

App 19183 output: �[33m[2020-03-26 09:29:22.650] [WARN] client - �[39mUncaught 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 ?

@JohnMcLear
Copy link
Member

JohnMcLear commented Mar 31, 2020

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

@JohnMcLear
Copy link
Member

@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?

@JohnMcLear
Copy link
Member

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.

@fnetX
Copy link

fnetX commented Apr 1, 2020

Please look at #3405 (comment) - 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.

@JohnMcLear
Copy link
Member

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

@fnetX
Copy link

fnetX commented Apr 1, 2020

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.

@xshadow
Copy link

xshadow commented Apr 1, 2020

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

@lvarnava
Copy link

lvarnava commented Jun 23, 2020

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

@webzwo0i webzwo0i reopened this Jun 23, 2020
@JohnMcLear
Copy link
Member

JohnMcLear commented Jun 23, 2020

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.

@JohnMcLear
Copy link
Member

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

@JohnMcLear
Copy link
Member

JohnMcLear commented Jun 23, 2020

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?

@JohnMcLear
Copy link
Member

JohnMcLear commented Jun 23, 2020

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

@lvarnava
Copy link

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

@webzwo0i
Copy link
Member

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.

@JohnMcLear
Copy link
Member

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

@webzwo0i
Copy link
Member

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

@JohnMcLear
Copy link
Member

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

@webzwo0i
Copy link
Member

I think there was some issue in jquery or the way we use it, that was easily triggerable and is now resolved with 128f3e1
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.

@cdruet
Copy link

cdruet commented Oct 19, 2020

@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!

@JohnMcLear
Copy link
Member

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

@mrtopf
Copy link

mrtopf commented Oct 19, 2020

@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)

@cdruet
Copy link

cdruet commented Oct 19, 2020 via email

@rhansen
Copy link
Member

rhansen commented Oct 19, 2020

@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.

@JohnMcLear
Copy link
Member

@rhansen can this be closed now?

@JohnMcLear JohnMcLear added this to the 1.9 milestone Oct 24, 2020
@rhansen rhansen closed this as completed Oct 25, 2020
@mrtopf
Copy link

mrtopf commented Oct 28, 2020

@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!

@ptandler
Copy link

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

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…fine&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…fine&v=564a4939:207
  (anonymous) @ pad.js?callback=requ…fine&v=564a4939:484
  mightThrow @ ace2_common.js?callb…ine&v=564a4939:3910
  process @ ace2_common.js?callb…ine&v=564a4939:3978
  setTimeout (async)    
  (anonymous) @ ace2_common.js?callb…ine&v=564a4939:4016
  fire @ ace2_common.js?callb…ine&v=564a4939:3645
  add @ ace2_common.js?callb…ine&v=564a4939:3704
  (anonymous) @ ace2_common.js?callb…ine&v=564a4939:4036
  Deferred @ ace2_common.js?callb…ine&v=564a4939:4120
  then @ ace2_common.js?callb…ine&v=564a4939:4021
  jQuery.fn.ready @ ace2_common.js?callb…ine&v=564a4939:4198
  init @ pad.js?callback=requ…fine&v=564a4939:480
  init @ pad.js?callback=requ…fine&v=564a4939:960
  (anonymous) @ test1?lang=de:725
  setTimeout (async)    
  callback @ ace2_common.js?callb…ne&v=564a4939:12053
  (anonymous) @ ace2_common.js?callb…ne&v=564a4939:12060
  fire @ ace2_common.js?callb…ine&v=564a4939:3645
  fireWith @ ace2_common.js?callb…ine&v=564a4939:3775
  done @ ace2_common.js?callb…ine&v=564a4939:9466
  (anonymous) @ ace2_common.js?callb…ine&v=564a4939:9708
  load (async)    
  send @ ace2_common.js?callb…ine&v=564a4939:9727
  ajax @ ace2_common.js?callb…ine&v=564a4939:9367
  jQuery. @ ace2_common.js?callb…ine&v=564a4939:9516
  getJSON @ ace2_common.js?callb…ine&v=564a4939:9497
  exports.update @ ace2_common.js?callb…ne&v=564a4939:12055
  (anonymous) @ test1?lang=de:717
  (anonymous) @ test1?lang=de:735

@rhansen
Copy link
Member

rhansen commented Nov 11, 2020

when is the next release expected?

Soon. Hopefully this week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests