"TypeError: Cannot read property '_id' of undefined" and other errors
Opened this issue · 8 comments
$ git clone https://github.com/feathersjs/feathers-chat.git
Clonage dans 'feathers-chat'...
remote: Counting objects: 901, done.
remote: Compressing objects: 100% (16/16), done.
remote: Total 901 (delta 5), reused 16 (delta 3), pack-reused 881
Réception d'objets: 100% (901/901), 909.87 KiB | 407.00 KiB/s, fait.
Résolution des deltas: 100% (431/431), fait.
$ cd feathers-chat
$ npm install
> uws@0.14.5 install […]\feathers-chat\node_modules\uws
> node-gyp rebuild > build_log.txt 2>&1 || exit 0
npm WARN feathers-chat@0.0.0 No repository field.
npm WARN feathers-chat@0.0.0 No license field.
added 474 packages in 46.802s
$ npm start
> feathers-chat@0.0.0 start […]\feathers-chat
> node src/
info: Feathers application started on http://localhost:3030
At 1st launch only: (???)
error: NotFound: Page not found
at new NotFound ([…]\feathers-chat\node_modules@feathersjs\errors\lib\index.js:109:17)
at […]\feathers-chat\node_modules@feathersjs\errors\lib\not-found-handler.js:5:10
at Layer.handle [as handle_request] ([…]\feathers-chat\node_modules\express\lib\router\layer.js:95:5)
at trim_prefix ([…]\feathers-chat\node_modules\express\lib\router\index.js:317:13)
at […]\feathers-chat\node_modules\express\lib\router\index.js:284:7
at Function.process_params ([…]\feathers-chat\node_modules\express\lib\router\index.js:335:12)
at next ([…]\feathers-chat\node_modules\express\lib\router\index.js:275:10)
at exposeHeaders ([…]\feathers-chat\node_modules@feathersjs\authentication\lib\express\expose-headers.js:10:5)
at Layer.handle [as handle_request] ([…]\feathers-chat\node_modules\express\lib\router\layer.js:95:5)
at trim_prefix ([…]\feathers-chat\node_modules\express\lib\router\index.js:317:13)
When I send a message (vanilla or jquery) :
- At first the message is not stored :
error: TypeError: Cannot read property '_id' of undefined
at Object.<anonymous> ([…]\feathers-chat\src\hooks\process-message.js:24:20)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)
- After reloading the page in the browser (I guess) the message is stored but not displayed :
error: Error: An id must be provided to the 'get' method
at validateArguments ([…]\feathers-chat\node_modules@feathersjs\commons\lib\arguments.js:47:15)
at Object.mixin.(anonymous function) ([…]\feathers-chat\node_modules@feathersjs\feathers\lib\hooks.js:41:9)
at Object.get ([…]\feathers-chat\node_modules\uberproto\lib\proto.js:30:17)
at Promise.all.messages.map ([…]\feathers-chat\src\hooks\populate-user.js:18:47)
at Array.map (<anonymous>)
at Object.<anonymous> ([…]\feathers-chat\src\hooks\populate-user.js:15:32)
at <anonymous>
I can switch back to the 1st behaviour if I delete the user.db files.
At a point (?) the user list is emptied ("0 users").
node-v8.9.4-win-x64
Thank you in advance for any help
I just tried the application and it seems to be working as expected. The page not found error is the browser looking for a favicon.ico
which is fine. For the other problems two things to try:
- Remove the old data (
rm -rf data/
) to make sure to start from scratch - Try opening the chat in an incognito window or clear the localstorage (
localStorage.clear()
in the devTools)
Same behaviour in a Firefox "private" window and after localStore.clear()
Same behaviour with Edge, and in an Edge "inPrivate" window.
If I delete the data files and restart the server, the browser is not logged out : the message page is emptied (no more user) but not redirected to the login page after reloading.
TY
Did you see the signup and login page? Did it create the user (it should show up in data/users.db
)?
Yes I can sign up, sign out, and sign in. Of course I get an error with an unknown user or wrong password.
The users.db
file is created and filled with user data.
In the message page the user list on the left is populated with the user mail addresses – when it is not empty after reloading the page and the error in populate-user.js
.
The project has been cloned from scratch (the feathers-chat
directory did not exist before that). My global node-modules
only contains npm
, forever
and @featherstjs/cli
.
v0.2.0
works fine
TY
Odd that 0.2.0 works. I just tried master with a fresh clone on a new Windows VM using Node 9.5.0 and I still can't reproduce those issues so I'm not sure what's happening for you there.
I think I found out the problem: MSYS. If I start the app from a standard Windows console it works fine!
For whatever reason from MSYS the browser cannot get a proper user._id. Yes: odd. Any idea? A DLL conflict?
I suppose this issue can be closed. Many thanks for your help.
What an odd issue. Maybe something got busted during the build or something. I'd probably go with either using just Windows or a VM to avoid things problems like that.
I had this issue as well. Same cause. I started the process in Cygwin and had the same error. I started under Windows cmd and it worked w/o issue. You may want to put a caveat in the tutorial / code on the line that fails:
process-message.js ln 24
// Update the original data (so that people can't submit additional stuff)
context.data = {
text,
// Set the user id
userId: user._id,