Skip to content
This repository has been archived by the owner on Nov 29, 2017. It is now read-only.

Server Crash On POST #200

Closed
CapitalLlama opened this issue Sep 18, 2016 · 10 comments
Closed

Server Crash On POST #200

CapitalLlama opened this issue Sep 18, 2016 · 10 comments
Labels

Comments

@CapitalLlama
Copy link

Anytime data is pushed to my private server, phant crashes with this error.

/usr/local/lib/node_modules/phant/lib/validator.js:173
      if (!data.hasOwnProperty(key)) {
                ^

TypeError: data.hasOwnProperty is not a function
    at /usr/local/lib/node_modules/phant/lib/validator.js:173:17
    at /usr/local/lib/node_modules/phant/node_modules/phant-meta-nedb/lib/phant-meta-nedb.js:188:5
                                                                                    at callback (/usr/local/lib/node_mod
ules/phant/node_modules/phant-meta-nedb/node_modules/nedb/lib/executor.js:30:17)
                                            at Cursor.execFn (/usr/local/lib/node_modules/phant/node_modules/phant-meta-
nedb/node_modules/nedb/lib/datastore.js:449:14)
    at Cursor._exec (/usr/local/lib/node_modules/phant/node_modules/phant-meta-nedb/node_modules/nedb/lib/cursor.js:172:
17)
at /usr/local/lib/node_modules/phant/node_modules/phant-meta-nedb/node_modules/nedb/lib/executor.js:40:13
                                                                                at Immediate.q.process (/usr/local/lib/n
ode_modules/phant/node_modules/phant-meta-nedb/node_modules/nedb/node_modules/async/lib/async.js:731:21)
                                        at runCallback (timers.js:574:20)
                                        at tryOnImmediate (timers.js:554:5)
                                        at processImmediate [as _immediateCallback] (timers.js:533:5)

I know the server was working about a week ago, and I have not edited any of the source code.
Currently on nodejs 6.6 and phant is run at startup by using etc/rc.local

Any ideas on what is causing this or how to fix it?

@botamochi6277
Copy link

I have the same problem (macOS Sierra, ver. 10.12, macbookAir, nodeJS v6.5.0).
I seriously hope to fix the problem.

phant-crush

@AWROUND
Copy link

AWROUND commented Oct 23, 2016

Identical issue on new install of local Phant server (Vagrant/VirtualBox on Windows 10 machine).
NodeJS Ver 6.8.1

@bergvdm
Copy link

bergvdm commented Oct 24, 2016

Same here after a fresh install (macOS 10.12 nodeJS v6.9.1)

@bergvdm
Copy link

bergvdm commented Oct 24, 2016

I did a search on Stackoverflow and might found a solution by changing (validator.js) line 173 to
if (!Object.hasOwnProperty.call(data, key)) {
and line 196 to
if (!Object.hasOwnProperty.call(data, stream.fields[i])) {
Seems to work, no more errors on posts.

Also found that Peter Stojcsics did the same on his fork, also in some other files.

@stoto
Copy link

stoto commented Oct 25, 2016

That's right. The main fork of Phant is made for an older version of nodejs. In the 6.x nodeJS, you can't call hasOwnProperty on any object, instead you have to use the mentioned syntax for the exact same thing.

The only thing I changed in my fork is this fix and I also removed the build status from the readme. You can fork it and use it ;)

@structure7
Copy link

That fix seems to be working with NodeJS v7.1.0, too.

@SwizzleMaster
Copy link

Changing the code didn't work for me. The other way to fix it is to downgrade to nodejs version 4.6.2. That version works fine for me.
First you'll need to npm install a node version manager called n : " npm install n ".
check it out here: https://github.com/tj/n

Once the version manager is installed, you install the working version of node and the stable version. " n 4.6.2 && n stable ".... then you choose which version you want to use: " n" then press the arrow keys up/down to select and the right-arrow key to set it as your version. you can verify that it worked by typing " node -v ".

After that you install phant and carry on as usual. you may or may not have to update your npm. check the readme in the n version manager github page about that.

good luck :)

@davidcie
Copy link

Came across the same and even upgraded from v7.6.0 to v7.7.2. Perhaps README.md should not say "requires the latest version of node.js" if what it really needs is v4.6.2. Hoping that @stoto can submit a PR with his fixes so that fewer new users are caught by this issue.

@ultrafez
Copy link

@stoto's PR is here for those interested.

@bboyho
Copy link
Contributor

bboyho commented Nov 28, 2017

Phant is No Longer in Operation

Unfortunately Phant, our data-streaming service, is no longer in service and will be discontinued. The system has reached capacity and, like a less-adventurous Cassini, has plunged conclusively into a fiery and permanent retirement. There are several other maker-friendly, data-streaming services and/or IoT platforms available as alternatives. The three we recommend are Blynk, ThingSpeak, and Cayenne. You can read our blog post [ https://www.sparkfun.com/news/2413 ] on the topic for an overview and helpful links for each platform.

@bboyho bboyho closed this as completed Nov 28, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests