Last modified: 2013-09-03 16:33:50 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T54840, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 52840 - express/connect version dependency issue in ParserService.js
express/connect version dependency issue in ParserService.js
Status: RESOLVED WORKSFORME
Product: Parsoid
Classification: Unclassified
Web API (Other open bugs)
unspecified
All All
: Normal normal
: ---
Assigned To: Gabriel Wicke
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2013-08-14 11:29 UTC by Marc Ordinas i Llopis
Modified: 2013-09-03 16:33 UTC (History)
4 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Marc Ordinas i Llopis 2013-08-14 11:29:46 UTC
Right now package.json specifies a dependency on express 2.5.x, but that version doesn't parse req.body by default, which is needed in ParserService.js:635. Upgrading it to 3.x.x seems to solve the problem:
https://www.mediawiki.org/wiki/Talk:Parsoid#TypeError:_Cannot_read_property_.27oldid.27_of_undefined
Comment 1 C. Scott Ananian 2013-08-14 14:38:08 UTC
Express 3.x.x is a major version change, it probably breaks lots of stuff.  I'm running with 2.5.11 on my machine (and I suspect the rest of the developers are, too).  Can you provide more details on the problem you're seeing?
Comment 2 Marc Ordinas i Llopis 2013-08-14 14:44:05 UTC
This is a traceback of the problem, as reported by an user on IRC:

TypeError: Cannot read property 'oldid' of undefined
    at app.post.cb (/opt/bitnami/apache2/htdocs/extensions/Parsoid/js/api/ParserService.js:635:28)
    at getParserServiceEnv (/opt/bitnami/apache2/htdocs/extensions/Parsoid/js/api/ParserService.js:376:4)
    at MWParserEnvironment.getParserEnv (/opt/bitnami/apache2/htdocs/extensions/Parsoid/js/lib/mediawiki.parser.environment.js:279:3)
    at MWParserEnvironment.switchToConfig (/opt/bitnami/apache2/htdocs/extensions/Parsoid/js/lib/mediawiki.parser.environment.js:324:3)
    at Function.MWParserEnvironment.getParserEnv (/opt/bitnami/apache2/htdocs/extensions/Parsoid/js/lib/mediawiki.parser.environment.js:278:6)
    at getParserServiceEnv (/opt/bitnami/apache2/htdocs/extensions/Parsoid/js/api/ParserService.js:365:22)
    at /opt/bitnami/apache2/htdocs/extensions/Parsoid/js/api/ParserService.js:663:2
    at callbacks (/opt/bitnami/apache2/htdocs/extensions/Parsoid/js/node_modules/express/lib/router/index.js:272:11)
    at param (/opt/bitnami/apache2/htdocs/extensions/Parsoid/js/node_modules/express/lib/router/index.js:246:11)
    at pass (/opt/bitnami/apache2/htdocs/extensions/Parsoid/js/node_modules/express/lib/router/index.js:253:5)

From further debugging (http://pastebin.com/DbBhJdEE), it seemed like the version of express the user had installed didn't provide req.body. Maybe 3.x.x isn't necessary, but 2.5.11 is?
Comment 3 C. Scott Ananian 2013-08-14 15:19:46 UTC
I think the problem is actually with connect (which provides the bodyParser middleware).  We're using connect version 1.9.2, but express only requires connect '1.x'.  As far as I can tell from https://github.com/senchalabs/connect/blob/master/History.md, the latest stable 1.x version was 1.8.5, and bodyParser was added/extended in connect 2.0.0.  I'm guessing that connect 1.9.2 is a "prerelease 2.0" and so contains some connect 2.0.0 features, like bodyParser.

If someone can reproduce this bug, I'd like to see what happens if they edit node_modules/express/package.json to depend on connect 1.9.x instead of 1.x, and then npm install from the node_modules/express directory.

Alternatively, we might suggest that people clone mediawiki/extensions/Parsoid/js/contrib.git instead of using npm install?

Probably the best way to solve this issue is to go ahead and migrate to express 3.0.  See https://github.com/visionmedia/express/wiki/Migrating-from-2.x-to-3.x and https://github.com/visionmedia/express/wiki/New-features-in-3.x.  Anyone want to tackle this?
Comment 4 Gabriel Wicke 2013-08-14 23:08:34 UTC
I just wiped & re-installed my dependencies without encountering this issue. If there is no way to reproduce this I'd suggest closing it as worksforme.
Comment 5 ssastry 2013-08-14 23:27:18 UTC
Multiple people seems to have reported the bug @ https://www.mediawiki.org/wiki/Talk:Parsoid .. so we still need to figure out what is breaking for them.
Comment 6 Gabriel Wicke 2013-08-15 00:34:47 UTC
That might well have been a temporary npm dependency issue.
Comment 7 C. Scott Ananian 2013-08-15 01:27:36 UTC
It was most recently reported this morning.
Comment 8 Gabriel Wicke 2013-08-15 05:56:17 UTC
Might be worth checking if people experiencing this issue actually did a clean install (rm -rf node_modules; npm install), or if there are other special circumstances like Windows or node 0.10.
Comment 9 C. Scott Ananian 2013-08-15 16:16:59 UTC
Yeah, agreed.  I'm hoping that someone else stumbles across this so we can debug more in depth.  In the meantime, I'd like to double-check the version of express/connect we're using in production, since we don't typically exercise this particular API during development.  I don't expect to be surprised, but you never know...
Comment 10 Gabriel Wicke 2013-08-15 16:50:22 UTC
Production and local tests are both fine, which is why I suspect temporary npm issues or special circumstances.
Comment 11 C. Scott Ananian 2013-08-15 17:01:50 UTC
Oh, I don't think that production is broken.  I'm just curious to know what version of express/connect got installed.  I expect to see them identical to the ones in contrib.  But you know, sometimes computers surprise you.
Comment 12 Gabriel Wicke 2013-08-15 23:51:45 UTC
FWIW, both production and my local (re)install have express 2.5.11 and connect 1.9.2. Anybody- please make sure you run npm install after a fresh checkout or after deleting node_modules. Please report your system info if the problem persists:

node --version
npm list
operating system
Comment 13 C. Scott Ananian 2013-08-16 16:51:57 UTC
Thanks for checking production, gwicke.
Comment 14 Gabriel Wicke 2013-08-19 19:20:52 UTC
So- anybody still experiencing this in the wild?
Comment 15 Imex 2013-08-21 08:39:45 UTC
I have the same problem.
[root@localhost api]# node --version
v0.8.22
[root@localhost api]# npm list
mediawiki-parsoid@0.0.1 /var/www/html/wiki/extensions/Parsoid/js
├── alea@0.0.9
├─┬ assert@0.4.9
│ └─┬ util@0.4.9
│   └── events.node@0.4.9
├── async@0.2.9
├── colors@0.6.1
├── diff@1.0.5
├── domino@1.0.12
├── entities@0.2.2
├── events@0.5.0
├─┬ express@2.5.11
│ ├─┬ connect@1.9.2
│ │ └── formidable@1.0.14
│ ├── mime@1.2.4
│ ├── mkdirp@0.3.0
│ └── qs@0.4.2
├── lru-cache@1.1.1
├─┬ optimist@0.6.0
│ ├── minimist@0.0.1
│ └── wordwrap@0.0.2
├── path@0.4.9
├── pegjs@0.7.0
├── querystring@0.2.0
└─┬ request@2.27.0
  ├── aws-sign@0.3.0
  ├── cookie-jar@0.3.0
  ├── forever-agent@0.5.0
  ├─┬ form-data@0.1.0
  │ └─┬ combined-stream@0.0.4
  │   └── delayed-stream@0.0.5
  ├─┬ hawk@1.0.0
  │ ├── boom@0.4.2
  │ ├── cryptiles@0.2.2
  │ ├── hoek@0.9.1
  │ └── sntp@0.2.4
  ├─┬ http-signature@0.10.0
  │ ├── asn1@0.1.11
  │ ├── assert-plus@0.1.2
  │ └── ctype@0.5.2
  ├── json-stringify-safe@5.0.0
  ├── mime@1.2.11
  ├── node-uuid@1.4.1
  ├── oauth-sign@0.3.0
  ├── qs@0.6.5
  └── tunnel-agent@0.3.0
OS: CentOS 6.4
On server: 
ERROR in localhost:Sistem:
Page Fetch failure for null
Stack trace: DoesNotExistError: Page Fetch failure for null
worker 2843 died (1), restarting.
 - worker(2876) loading...
 - worker(2876) ready
Comment 16 Gabriel Wicke 2013-08-21 16:55:04 UTC
(In reply to comment #15)
> I have the same problem.

Your dependencies look fine to me, so it is not related to the issue discussed in this bug.

> On server: 
> ERROR in localhost:Sistem:
> Page Fetch failure for null
> Stack trace: DoesNotExistError: Page Fetch failure for null

Parsoid clearly started up ok, but could not fetch the page 'Sistem:' from the API. Check that this page actually exists and that your API url is configured properly in localsettings.js. Try different pages like http://localhost:8000/localhost/Main_Page in case there is a page called 'Main_Page' in your wiki.
Comment 17 Gabriel Wicke 2013-08-23 16:01:01 UTC
Since we have not been able to reproduce this and have additional reports about successful installs (see for example #15) I am going to close this bug as worksforme. If anybody experiences this after a clean install (after deleting node_modules), then please reopen and provide

node --version
npm list
operating system
Comment 18 Stu Maitland 2013-09-02 10:37:42 UTC
I'm still having problems with the above issue:

On server:
/var/www/vhosts/website.co.uk/httpdocs/Parsoid/js/api/ParserService.js:639
                var doc, oldid = req.body.oldid || null;
                                         ^
TypeError: Cannot read property 'oldid' of undefined
    at app.post.cb (/var/www/vhosts/website.co.uk/httpdocs/Parsoid/js/api/ParserService.js:639:28)
    at getParserServiceEnv (/var/www/vhosts/website.co.uk/httpdocs/Parsoid/js/api/ParserService.js:380:4)
    at MWParserEnvironment.getParserEnv (/var/www/vhosts/website.co.uk/httpdocs/Parsoid/js/lib/mediawiki.parser.environment.js:279:3)
    at setupWikiConfig (/var/www/vhosts/website.co.uk/httpdocs/Parsoid/js/lib/mediawiki.parser.environment.js:299:3)
    at ApiRequest._processListeners.processSome (/var/www/vhosts/website.co.uk/httpdocs/Parsoid/js/lib/mediawiki.ApiRequest.js:107:17)
    at process.startup.processNextTick.process._tickCallback (node.js:245:9)
worker 3410 died (1), restarting.

node --version v0.825
npm list
--- alea@0.0.9
---¬ assert@0.4.9
- ---¬ util@0.4.9
-   --- events.node@0.4.9
--- async@0.2.9
--- colors@0.6.0-1
--- diff@1.0.5
--- domino@1.0.12
--- entities@0.2.2
--- events@0.5.0
---¬ express@2.5.0
- ---¬ connect@1.7.0
- - --- mime@1.2.11
- --- mime@1.2.11
- --- mkdirp@0.0.7
- --- qs@0.6.5
--- html5-entities@0.5.0
--- lru-cache@1.0.1
---¬ optimist@0.6.0
- --- minimist@0.0.2
- --- wordwrap@0.0.2
--- path@0.4.9
--- pegjs@0.7.0
--- querystring@0.2.0
---¬ request@2.27.0
  --- aws-sign@0.3.0
  --- cookie-jar@0.3.0
  --- forever-agent@0.5.0
  ---¬ form-data@0.1.1
  - ---¬ combined-stream@0.0.4
  -   --- delayed-stream@0.0.5
  ---¬ hawk@1.0.0
  - ---¬ boom@0.4.0
  - - --- hoek@0.8.0
  - --- cryptiles@0.2.2
  - --- hoek@0.9.0
  - --- sntp@0.2.4
  ---¬ http-signature@0.10.0
  - --- asn1@0.1.11
  - --- assert-plus@0.1.2
  - --- ctype@0.5.2
  --- json-stringify-safe@5.0.0
  --- mime@1.2.11
  --- node-uuid@1.4.1
  --- oauth-sign@0.3.0
  --- qs@0.6.5
  --- tunnel-agent@0.3.0

OS: Ubuntu 12.04.2 LTS
Comment 19 Marc Ordinas i Llopis 2013-09-02 16:18:05 UTC
Stu, it seems you have old versions of express and connect, which will produce this error. Can you try to delete Parsoid/js/node_modules and do 'npm install' again, see if the error goes away?
Comment 20 Stu Maitland 2013-09-02 17:04:12 UTC
Thanks Marc,
Still receiving this error after I performed delete then npm install, which yielded the same --version. Force updated express with npm install -f express@3.x
npm list
--- alea@0.0.9
---¬ assert@0.4.9
- ---¬ util@0.4.9
-   --- events.node@0.4.9
--- async@0.2.9
--- colors@0.6.2
--- diff@1.0.6
--- domino@1.0.12
--- entities@0.2.2
--- events@0.5.0
---¬ express@3.3.8 invalid
- --- buffer-crc32@0.2.1
- ---¬ commander@1.2.0
- - --- keypress@0.1.0
- ---¬ connect@2.8.8
- - --- bytes@0.2.0
- - --- formidable@1.0.14
- - --- pause@0.0.1
- - --- qs@0.6.5
- - --- uid2@0.0.2
- --- cookie@0.1.0
- --- cookie-signature@1.0.1
- --- debug@0.7.2
- --- fresh@0.2.0
- --- methods@0.0.1
- --- mkdirp@0.3.5
- --- range-parser@0.0.4
- ---¬ send@0.1.4
-   --- mime@1.2.11
--- html5-entities@0.5.0
--- lru-cache@1.0.1
---¬ optimist@0.6.0
- --- minimist@0.0.2
- --- wordwrap@0.0.2
--- path@0.4.9
--- pegjs@0.7.0
--- querystring@0.2.0
---¬ request@2.27.0
  --- aws-sign@0.3.0
  --- cookie-jar@0.3.0
  --- forever-agent@0.5.0
  ---¬ form-data@0.1.1
  - ---¬ combined-stream@0.0.4
  -   --- delayed-stream@0.0.5
  ---¬ hawk@1.0.0
  - ---¬ boom@0.4.0
  - - --- hoek@0.8.0
  - --- cryptiles@0.2.2
  - --- hoek@0.9.0
  - --- sntp@0.2.4
  ---¬ http-signature@0.10.0
  - --- asn1@0.1.11
  - --- assert-plus@0.1.2
  - --- ctype@0.5.2
  --- json-stringify-safe@5.0.0
  --- mime@1.2.11
  --- node-uuid@1.4.1
  --- oauth-sign@0.3.0
  --- qs@0.6.5
  --- tunnel-agent@0.3.0

On server:
/var/www/vhosts/website.co.uk/httpdocs/Parsoid/js/api/ParserService.js:639
                var doc, oldid = req.body.oldid || null;
                                         ^
TypeError: Cannot read property 'oldid' of undefined
    at app.post.cb (/var/www/vhosts/website.co.uk/httpdocs/Parsoid/js/api/ParserService.js:639:28)
    at getParserServiceEnv (/var/www/vhosts/website.co.uk/httpdocs/Parsoid/js/api/ParserService.js:380:4)
    at MWParserEnvironment.getParserEnv (/var/www/vhosts/website.co.uk/httpdocs/Parsoid/js/lib/mediawiki.parser.environment.js:279:3)
    at setupWikiConfig (/var/www/vhosts/website.co.uk/httpdocs/Parsoid/js/lib/mediawiki.parser.environment.js:299:3)
    at ApiRequest._processListeners.processSome (/var/www/vhosts/website.co.uk/httpdocs/Parsoid/js/lib/mediawiki.ApiRequest.js:107:17)
    at process.startup.processNextTick.process._tickCallback (node.js:245:9)
worker 7538 died (1), restarting.
 - worker(7791) loading...
Warning: express.createServer() is deprecated, express
applications no longer inherit from http.Server,
please use:

  var express = require("express");
  var app = express();
Comment 21 Marc Ordinas i Llopis 2013-09-02 17:09:14 UTC
Thanks for the info. It's strange that npm install doesn't give the same versions as the ones we get in production (express 2.5.11 and connect 1.9.2). Could you try with those, see if the error is still present?
Comment 22 Stu Maitland 2013-09-02 20:18:15 UTC
Hi Marc,
Sadly still going:

npm list:

--- alea@0.0.9
---¬ assert@0.4.9
- ---¬ util@0.4.9
-   --- events.node@0.4.9
--- async@0.2.9
--- colors@0.6.2
---¬ connect@1.9.2 extraneous
- --- formidable@1.0.14
- --- mime@1.2.11
- --- qs@0.6.5
--- diff@1.0.6
--- domino@1.0.12
--- entities@0.2.2
--- events@0.5.0
---¬ express@2.5.11
- --- connect@1.0.0
- --- mime@1.2.4
- --- mkdirp@0.3.0
- --- qs@0.4.0
--- html5-entities@0.5.0
--- lru-cache@1.0.1
---¬ optimist@0.6.0
- --- minimist@0.0.2
- --- wordwrap@0.0.2
--- path@0.4.9
--- pegjs@0.7.0
--- querystring@0.2.0
---¬ request@2.27.0
  --- aws-sign@0.3.0
  --- cookie-jar@0.3.0
  --- forever-agent@0.5.0
  ---¬ form-data@0.1.1
  - ---¬ combined-stream@0.0.4
  -   --- delayed-stream@0.0.5
  ---¬ hawk@1.0.0
  - ---¬ boom@0.4.0
  - - --- hoek@0.8.0
  - --- cryptiles@0.2.2
  - --- hoek@0.9.0
  - --- sntp@0.2.4
  ---¬ http-signature@0.10.0
  - --- asn1@0.1.11
  - --- assert-plus@0.1.2
  - --- ctype@0.5.2
  --- json-stringify-safe@5.0.0
  --- mime@1.2.11
  --- node-uuid@1.4.1
  --- oauth-sign@0.3.0
  --- qs@0.6.5
  --- tunnel-agent@0.3.0

On server:
/var/www/vhosts/website.co.uk/httpdocs/Parsoid/js/api/ParserService.js:639
                var doc, oldid = req.body.oldid || null;
                                         ^
TypeError: Cannot read property 'oldid' of undefined
    at app.post.cb (/var/www/vhosts/website.co.uk/httpdocs/Parsoid/js/api/ParserService.js:639:28)
    at getParserServiceEnv (/var/www/vhosts/website.co.uk/httpdocs/Parsoid/js/api/ParserService.js:380:4)
    at MWParserEnvironment.getParserEnv (/var/www/vhosts/website.co.uk/httpdocs/Parsoid/js/lib/mediawiki.parser.environment.js:279:3)
    at setupWikiConfig (/var/www/vhosts/website.co.uk/httpdocs/Parsoid/js/lib/mediawiki.parser.environment.js:299:3)
    at ApiRequest._processListeners.processSome (/var/www/vhosts/website.co.uk/httpdocs/Parsoid/js/lib/mediawiki.ApiRequest.js:107:17)
    at process.startup.processNextTick.process._tickCallback (node.js:245:9)
worker 10557 died (1), restarting.
Comment 23 Marc Ordinas i Llopis 2013-09-03 16:20:25 UTC
Stu, sorry to keep banging on this, but you seem to have a very old version of connect (1.0.0), we use 1.9.2 in production.
Comment 24 Stu Maitland 2013-09-03 16:33:50 UTC
Thanks very much for your help Marc; I had installed the updated connect in the root folder, rather than under express, it's all working now.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links