Closed interstar closed 9 years ago
OK. I seem to be having similar issues when trying to run from the source here on Github.
I'm looking in the example directory. I modified the server to run on port 7050 (port 80 is already in use on this machine) and change the file path. I then tried to create the user
curl -kX POST https://local.dev/signup -d 'username=phil' -d 'email=phil@test.com' -d 'password=test'
and the server blows up with
/home/phil/Documents/development/testing_frameworks/remote-storage/restore/node_modules/ejs/lib/ejs.js:128
throw err;
^
ReferenceError: ejs:3
1| <h2>You’ve signed up</h2>
2|
>> 3| <p>Thanks, <em><%= params.username %></em>.</p>
4|
params is not defined
at eval (eval at <anonymous> (/home/phil/Documents/development/testing_frameworks/remote-storage/restore/node_modules/ejs/lib/ejs.js:302:12), <anonymous>:2:291)
at /home/phil/Documents/development/testing_frameworks/remote-storage/restore/node_modules/ejs/lib/ejs.js:328:17
at Object.exports.render (/home/phil/Documents/development/testing_frameworks/remote-storage/restore/node_modules/ejs/lib/ejs.js:177:13)
at Controller.renderHTML (/home/phil/Documents/development/testing_frameworks/remote-storage/restore/lib/controllers/base.js:111:17)
at /home/phil/Documents/development/testing_frameworks/remote-storage/restore/lib/controllers/users.js:19:12
at /home/phil/Documents/development/testing_frameworks/remote-storage/restore/lib/stores/file_tree.js:334:15
at /home/phil/Documents/development/testing_frameworks/remote-storage/restore/lib/stores/file_tree.js:360:13
at Object.oncomplete (fs.js:107:15)
Reproduced with current master. Maybe an upstream change in a dependency that wasn't pinned?
Sounds plausible. I'm not very knowledgable about the node ecosystem. This looks like it's a template (from ejs?) which isn't getting data to fill it.
Is that more likely to be a change in the ejs module? Or could it be something that I didn't configure that needs configuring?
Looks like params.username
should exist, but doesn't. So it's maybe a param parsing lib or sth else that touches the params in some way.
(Haven't read the code.)
Hey @interstar can you try my pull request: https://github.com/jcoglan/restore/pull/27 ? I'm not sure if this is the same issue, but I'd be interested to see if it resolved your problem.
Sorry if I'm double-posting, tried sending from phone but the network was in and out.
I just tried to reproduce this, but both curl as well as the webpage work for me when signing up.
@interstar It's fairly easy to understand what's going on when you follow the stack trace. The params are set on the controller here: https://github.com/jcoglan/restore/blob/master/lib/controllers/base.js#L18-L20 and passed to the ejs rendering function here: https://github.com/jcoglan/restore/blob/master/lib/controllers/users.js#L19
This is taking the argument and trying to render with the locals set to that object, and fails: https://github.com/jcoglan/restore/blob/master/lib/controllers/base.js#L111
Hope this helps with debugging.
Hmmm ... it's looking to me as if various times what is being sent to the ejs.render is a dictionary that contains another dictionary that contains the value to fill the slot in the template.
So something like signup_success.html is looking for params.username, but the value is actually in locals.params.username.
This seems to be happening all over the place. Could the templates have all suddenly developed errors? Or, given @skddc saying that it's working OK for him, could there be some kind of global switch which determines whether ejs recurses down through the dictionaries of objects looking for the value? Which is enabled for him but not for me?
@interstar Hey Phil, could you maybe explain step by step what you're doing? I think it's possible there's a disconnect somewhere along the line.
I just realized that I didn't do an npm install
btw. Just checked out master and started the example server. So that might affect what npm module version is in use, right?
Also, what Node version are you on? I'm using the latest 0.10.x
. People regularly run into things not working with 0.11.x
(the unstable branch).
@silverbucket Same problem with your 5... branch I'm afraid. It may be you resolved one part, but it's looking to me like there's a mismatch between the data being passed to the templates and the templates themselves.
@interstar like @skddc I'm not having any issues. Can you list out a step by step list to reproduce when you have the chance?
@silverbucket Here's what I'm doing :
git clone https://github.com/jcoglan/restore.git restore2
cd restore2
npm install
cd examples
I then edit the server.js file so that it contains :
var reStore = require('../lib/restore'),
store,
server;
var type = process.argv[2];
if (type === 'redis')
store = new reStore.Redis({database: 3});
else
store = new reStore.FileTree({path: __dirname + '/restore-test-data'});
server = new reStore({
store: store,
http: {port: 7050},
https: {
force: true,
port: 443,
cert: __dirname + '/ssl/server.crt',
key: __dirname + '/ssl/server.key'
},
allow: {
signup: true
},
cacheViews: false
});
server.boot();
Then I run :
sudo node server.js
And try the curl :
curl -kX POST https://local.dev/signup -d 'username=phil6' -d 'email=phil6@test.com' -d 'password=test'
First time I try to register the username it seems to work. But then blows up when trying to return a filled ejs template telling me it works :
/home/phil/Documents/development/testing_frameworks/remote-storage/restore2/node_modules/ejs/lib/ejs.js:128
throw err;
^
ReferenceError: ejs:3
1| <h2>You’ve signed up</h2>
2|
>> 3| <p>Thanks, <em><%= params.username %></em>.</p>
4|
params is not defined
at eval (eval at <anonymous> (/home/phil/Documents/development/testing_frameworks/remote-storage/restore2/node_modules/ejs/lib/ejs.js:303:12), <anonymous>:2:291)
at /home/phil/Documents/development/testing_frameworks/remote-storage/restore2/node_modules/ejs/lib/ejs.js:329:17
at Object.exports.render (/home/phil/Documents/development/testing_frameworks/remote-storage/restore2/node_modules/ejs/lib/ejs.js:177:13)
at Controller.renderHTML (/home/phil/Documents/development/testing_frameworks/remote-storage/restore2/lib/controllers/base.js:111:17)
at /home/phil/Documents/development/testing_frameworks/remote-storage/restore2/lib/controllers/users.js:19:12
at /home/phil/Documents/development/testing_frameworks/remote-storage/restore2/lib/stores/file_tree.js:334:15
at /home/phil/Documents/development/testing_frameworks/remote-storage/restore2/lib/stores/file_tree.js:360:13
at Object.oncomplete (fs.js:107:15)
That's because there is no params.username being passed to the template.
If I change the lib/views/signup-success.html template to refer to locals.params.username then it gets through this step, but crashes on the next
/home/phil/Documents/development/testing_frameworks/remote-storage/restore2/node_modules/ejs/lib/ejs.js:128
throw err;
^
ReferenceError: ejs:6
4| <head>
5| <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
>> 6| <link href="<%= scheme %>://fonts.googleapis.com/css?family=Ubuntu+Mono|Open+Sans:400italic,400,700" rel="stylesheet" type="text/css">
7| <title><%= title %></title>
8| <link rel="stylesheet" type="text/css" href="/assets/style.css">
9| </head>
scheme is not defined
at eval (eval at <anonymous> (/home/phil/Documents/development/testing_frameworks/remote-storage/restore2/node_modules/ejs/lib/ejs.js:303:12), <anonymous>:2:1134)
at /home/phil/Documents/development/testing_frameworks/remote-storage/restore2/node_modules/ejs/lib/ejs.js:329:17
at Object.exports.render (/home/phil/Documents/development/testing_frameworks/remote-storage/restore2/node_modules/ejs/lib/ejs.js:177:13)
at Controller.renderHTML (/home/phil/Documents/development/testing_frameworks/remote-storage/restore2/lib/controllers/base.js:114:29)
at /home/phil/Documents/development/testing_frameworks/remote-storage/restore2/lib/controllers/users.js:19:12
at /home/phil/Documents/development/testing_frameworks/remote-storage/restore2/lib/stores/file_tree.js:334:15
at /home/phil/Documents/development/testing_frameworks/remote-storage/restore2/lib/stores/file_tree.js:360:13
at Object.oncomplete (fs.js:107:15)
If I try to recreate with the same name, it obviously tries to report that the name is already in use and blows up on that. (No error value defined for the error reporting page). So it looks like a whole bunch of templates are out of sync with the program.
@skddc If I try it without running npm install it just blows up, telling me that it can't find the ejs module.
@skddc Here's the output of npm install
npm http GET https://registry.npmjs.org/mkdirp
npm http GET https://registry.npmjs.org/async
npm http GET https://registry.npmjs.org/ejs
npm http GET https://registry.npmjs.org/jstest
npm http GET https://registry.npmjs.org/redis
npm http GET https://registry.npmjs.org/rimraf
npm http 304 https://registry.npmjs.org/mkdirp
npm http 304 https://registry.npmjs.org/async
npm http 304 https://registry.npmjs.org/ejs
npm http 304 https://registry.npmjs.org/redis
npm http 304 https://registry.npmjs.org/jstest
npm http 304 https://registry.npmjs.org/rimraf
npm http GET https://registry.npmjs.org/minimist/0.0.8
npm http GET https://registry.npmjs.org/nopt
npm http 304 https://registry.npmjs.org/minimist/0.0.8
npm http 304 https://registry.npmjs.org/nopt
npm http GET https://registry.npmjs.org/abbrev
npm http 304 https://registry.npmjs.org/abbrev
rimraf@2.2.8 node_modules/rimraf
async@0.9.0 node_modules/async
redis@0.12.1 node_modules/redis
ejs@2.0.8 node_modules/ejs
mkdirp@0.5.0 node_modules/mkdirp
└── minimist@0.0.8
jstest@1.0.5 node_modules/jstest
└── nopt@3.0.1 (abbrev@1.0.5)
My node version seems to be v0.10.11 (I'm on Ubuntu 14.04, and I think node came from the Ubuntu package manager)
@interstar OK, this is definitely due to a recent update in the ejs
package. reStore
dependencies were not locked to just have patch level updates, so get any and all updates to modules, breaking or not.
I'll submit a pull request soon.
Hah, @interstar's first hunch was right all along. :)
@skddc yeah! I have had too many network issues to reliably use npm for a week until today, so was finally able to risk a fresh npm install
:)
@interstar the fix is submitted as #29 pretty simple change in the end, let me know if you run into any trouble using that branch.
Thanks @silverbucket
However, if I install your fix before calling npm install I get this :
npm http 304 https://registry.npmjs.org/redis
npm ERR! Error: No compatible version found: redis@'^0.12.1'
npm ERR! Valid install targets:
npm ERR! ["0.0.1","0.0.2","0.0.3","0.0.4","0.0.7","0.0.8","0.1.0","0.1.1","0.1.2","0.2.0","0.2.1","0.2.2","0.2.3","0.2.4","0.2.6","0.3.0","0.3.1","0.3.2","0.3.3","0.3.4","0.3.5","0.3.6","0.3.7","0.3.9","0.4.0","0.4.1","0.4.2","0.5.0","0.5.1","0.5.2","0.5.3","0.5.4","0.5.5","0.5.6","0.5.7","0.5.8","0.5.9","0.5.10","0.5.11","0.6.0","0.6.1","0.6.2","0.6.3","0.6.4","0.6.5","0.6.6","0.6.7","0.7.0","0.7.1","0.7.2","0.7.3","0.8.0","0.8.1","0.8.2","0.8.3","0.8.4","0.8.5","0.8.6","0.9.0","0.9.1","0.9.2","0.10.0","0.10.1","0.10.2","0.10.3","0.11.0","0.12.0","0.12.1"]
npm ERR! at installTargetsError (/usr/local/lib/node_modules/npm/lib/cache.js:719:10)
npm ERR! at /usr/local/lib/node_modules/npm/lib/cache.js:641:10
npm ERR! at saved (/usr/local/lib/node_modules/npm/node_modules/npm-registry-client/lib/get.js:138:7)
npm ERR! at Object.oncomplete (fs.js:107:15)
npm ERR! If you need help, you may report this log at:
npm ERR! <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR! <npm-@googlegroups.com>
npm ERR! System Linux 3.13.0-43-generic
npm ERR! command "/usr/local/bin/node" "/usr/local/bin/npm" "install"
npm ERR! cwd /home/phil/Documents/development/testing_frameworks/remote-storage/restore2
npm ERR! node -v v0.10.11
npm ERR! npm -v 1.2.30
npm http 304 https://registry.npmjs.org/mkdirp
npm http 304 https://registry.npmjs.org/async
npm http 304 https://registry.npmjs.org/ejs
npm http 304 https://registry.npmjs.org/jstest
npm http 304 https://registry.npmjs.org/rimraf
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /home/phil/Documents/development/testing_frameworks/remote-storage/restore2/npm-debug.log
npm ERR! not ok code 0
OK @silverbucket I had to remove the ^s from that package.json file, but things are looking more promising (curl user creation worked. Now to see if I can store my favourite drinks in restore)
OK. So now reStore looks like it's working. But I'm not sure if I'm doing the right thing.
I have reStore running on port 7050. When I go there in the browser I can create a new user etc. through the browser. I also have the starter-kit running into which I installed the "favourite drinks" app. I now log out of the starter-kit storage and try to connect the drinks-app to the reStore by putting in :
phil@localhost:7050 into the remoteStorage login on the favourite drinks page.
However, when it tries to take me there :
https://localhost:7050/oauth/phil?redirect_uri=http%3A%2F%2Flocalhost%3A1025%2F&scope=myfavoritedrinks%3Arw&client_id=http%3A%2F%2Flocalhost%3A1025&state=&response_type=token
the browser shows me a "Connection Interrupted" page.
The reStore server hasn't crashed, I can still navigate it directly in the browser pointing to 7050. But it doesn't seem to allow the favourite drinks app. to connect to it.
@interstar this is due to special handling when using localhost
as your domain. Try setting an alias in your /etc/hosts
for local.dev
(that's what I use, at least) which should escape the restrictions put on localhost
by the browser.
Hmmm .. I seem to have the same problem (interrupted connection) even when I use local.dev.
Could the port number could be an issue?
@interstar We're available on IRC for live debugging: https://webchat.freenode.net/?channels=remotestorage
Since this seems like a convenient place to notify everyone affected -- I'm taking an extended break from OSS work, and I hope to be back in February. Apologies for the interruption.
Thanks for the heads up @jcoglan (and for your work on reStore).
With @silverbucket's second patch (pull request #29 ) and a quick tweak to remove the ^s, this bug is basically resolved, but I'll leave it open so anyone else with this problem will see it, until that patch is pulled into this repo.
This was fixed in https://github.com/jcoglan/restore/commit/9ad0d26d571f2fe7a46cec78ed5a529e542266be and https://github.com/jcoglan/restore/commit/82ca6456c78cb5e333a49f1a84c076bd35215dde, thanks @silverbucket and apologies to everyone for my absence -- I had other projects to catch up on after my break.
I'm not sure how I'm meant to use this, but here's my first attempt.
I followed the README instructions : installed with npm, copied your example basic server script from the README file, changed the path-to-files to a real path and changed the port to 7050. I then executed the script with node.
I then tried to connect to the server from the favourite drinks example I'd installed in the starter-kit.
The server blew up immediately with the following error :