Error when Deploy meteor 1.6 app with PM2

Hi,

I migrate my app from meteor 1.5 to meteor 1.6 and install node v8.9.4 on my server.

My app run fine in local mode. When I deploy my app to my server using pm2-meteor the deploy went well and terminate with ok.

When I check on my server with pm2 list, I notice that my app is listed with error:
adaV4-NOVA-EN │ 1 │ cluster │ 0 │ errored │ 300 │ 0 │ 0% │ 0 B │ disabled

When I check with pm2 logs I got:
/root/.pm2/logs/adaV4-NOVA-EN-error-1.log last 10 lines:
1|adaV4-NO | at exports.runInThisContext (vm.js:53:16)
1|adaV4-NO | at Module._compile (module.js:373:25)
1|adaV4-NO | at Object.Module._extensions…js (module.js:416:10)
1|adaV4-NO | at Module.load (module.js:343:32)
1|adaV4-NO | at Function.Module._load (module.js:300:12)
1|adaV4-NO | at Function._load (/usr/local/lib/node_modules/pm2/node_modules/pmx/lib/transaction.js:92:21)
1|adaV4-NO | at Module.require (module.js:353:17)
1|adaV4-NO | at require (internal/module.js:12:17)
1|adaV4-NO | at Object. (/opt/pm2-meteor/nova/adaV4-NOVA-EN/bundle/main.js:4:1)
1|adaV4-NO | at Module._compile (module.js:409:26)

I read somewhere that I should install core-js so I install it on my development computer with:
meteor npm install --save core-js

But still got the same issue !

Any idea, how I can fix this issue ?

Thank You
Adalidda

Can you post more than the last 10 log lines?

Thank You coagmano.

Below are the logs:

Warning: fragment with name UsersCurrent already exists.
graphql-tag enforces all fragment names across your application to be unique; read more about
this in the docs: http://dev.apollodata.com/core/fragments.html#unique-names
Warning: fragment with name UsersCurrent already exists.
graphql-tag enforces all fragment names across your application to be unique; read more about
this in the docs: http://dev.apollodata.com/core/fragments.html#unique-names
Warning: fragment with name UsersCurrent already exists.
graphql-tag enforces all fragment names across your application to be unique; read more about
this in the docs: http://dev.apollodata.com/core/fragments.html#unique-names
Warning: fragment with name UsersCurrent already exists.
graphql-tag enforces all fragment names across your application to be unique; read more about
this in the docs: http://dev.apollodata.com/core/fragments.html#unique-names
Warning: fragment with name UsersCurrent already exists.
graphql-tag enforces all fragment names across your application to be unique; read more about
this in the docs: http://dev.apollodata.com/core/fragments.html#unique-names
You have triggered an unhandledRejection, you may have forgotten to catch a Promise rejection:
TypeError: The loader.load() function must be called with a value,but got: undefined.
at DataLoader.load (/opt/pm2-meteor/nova/adaV4-NOVA-EN/bundle/programs/server/npm/node_modules/dataloader/index.js:44:13)
at _callee$ (packages/vulcan:users/lib/schema.js:211:47)
at tryCatch (/opt/pm2-meteor/nova/adaV4-NOVA-EN/bundle/programs/server/npm/node_modules/regenerator-runtime/runtime.js:65:40)
at GeneratorFunctionPrototype.invoke [as _invoke] (/opt/pm2-meteor/nova/adaV4-NOVA-EN/bundle/programs/server/npm/node_modules/regen$
at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (/opt/pm2-meteor/nova/adaV4-NOVA-EN/bundle/programs/server/n$
at tryCatch (/opt/pm2-meteor/nova/adaV4-NOVA-EN/bundle/programs/server/npm/node_modules/regenerator-runtime/runtime.js:65:40)
at invoke (/opt/pm2-meteor/nova/adaV4-NOVA-EN/bundle/programs/server/npm/node_modules/regenerator-runtime/runtime.js:155:20)
at /opt/pm2-meteor/nova/adaV4-NOVA-EN/bundle/programs/server/npm/node_modules/regenerator-runtime/runtime.js:202:11
at new wrappedPromise (/usr/local/lib/node_modules/pm2/node_modules/async-listener/index.js:372:16)
at callInvokeWithMethodAndArg (/opt/pm2-meteor/nova/adaV4-NOVA-EN/bundle/programs/server/npm/node_modules/regenerator-runtime/runti$
You have triggered an unhandledRejection, you may have forgotten to catch a Promise rejection:
TypeError: The loader.load() function must be called with a value,but got: undefined.
at DataLoader.load (/opt/pm2-meteor/nova/adaV4-NOVA-EN/bundle/programs/server/npm/node_modules/dataloader/index.js:44:13)
at _callee$ (packages/vulcan:users/lib/schema.js:211:47)
at tryCatch (/opt/pm2-meteor/nova/adaV4-NOVA-EN/bundle/programs/server/npm/node_modules/regenerator-runtime/runtime.js:65:40)
at GeneratorFunctionPrototype.invoke [as _invoke] (/opt/pm2-meteor/nova/adaV4-NOVA-EN/bundle/programs/server/npm/node_modules/regen$
at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (/opt/pm2-meteor/nova/adaV4-NOVA-EN/bundle/programs/server/n$
at tryCatch (/opt/pm2-meteor/nova/adaV4-NOVA-EN/bundle/programs/server/npm/node_modules/regenerator-runtime/runtime.js:65:40)
at invoke (/opt/pm2-meteor/nova/adaV4-NOVA-EN/bundle/programs/server/npm/node_modules/regenerator-runtime/runtime.js:155:20)
at /opt/pm2-meteor/nova/adaV4-NOVA-EN/bundle/programs/server/npm/node_modules/regenerator-runtime/runtime.js:202:11
at new wrappedPromise (/usr/local/lib/node_modules/pm2/node_modules/async-listener/index.js:372:16)
at callInvokeWithMethodAndArg (/opt/pm2-meteor/nova/adaV4-NOVA-EN/bundle/programs/server/npm/node_modules/regenerator-runtime/runti$
You have triggered an unhandledRejection, you may have forgotten to catch a Promise rejection:
TypeError: The loader.load() function must be called with a value,but got: undefined.
at DataLoader.load (/opt/pm2-meteor/nova/adaV4-NOVA-EN/bundle/programs/server/npm/node_modules/dataloader/index.js:44:13)
at _callee$ (packages/vulcan:users/lib/schema.js:211:47)
at tryCatch (/opt/pm2-meteor/nova/adaV4-NOVA-EN/bundle/programs/server/npm/node_modules/regenerator-runtime/runtime.js:65:40)
at GeneratorFunctionPrototype.invoke [as _invoke] (/opt/pm2-meteor/nova/adaV4-NOVA-EN/bundle/programs/server/npm/node_modules/regen$
at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (/opt/pm2-meteor/nova/adaV4-NOVA-EN/bundle/programs/server/n$
at tryCatch (/opt/pm2-meteor/nova/adaV4-NOVA-EN/bundle/programs/server/npm/node_modules/regenerator-runtime/runtime.js:65:40)
at invoke (/opt/pm2-meteor/nova/adaV4-NOVA-EN/bundle/programs/server/npm/node_modules/regenerator-runtime/runtime.js:155:20)
at /opt/pm2-meteor/nova/adaV4-NOVA-EN/bundle/programs/server/npm/node_modules/regenerator-runtime/runtime.js:202:11
at new wrappedPromise (/usr/local/lib/node_modules/pm2/node_modules/async-listener/index.js:372:16)
at callInvokeWithMethodAndArg (/opt/pm2-meteor/nova/adaV4-NOVA-EN/bundle/programs/server/npm/node_modules/regenerator-runtime/runti$
Tue Aug 15 2017 05:04:14 GMT+0200 (CEST) ‘error while server-rendering’ 'Error: GraphQL error: The loader.load() function must be calle$
You have triggered an unhandledRejection, you may have forgotten to catch a Promise rejection:
Error: {“id”:“app.document_not_found”,“value”:“tkjhst8ktqdz33kfi”}
at Object.Utils.performCheck (packages/vulcan:lib/lib/modules/utils.js:459:11)
at Object._callee$ (packages/vulcan:posts/lib/resolvers.js:47:13)
at tryCatch (/opt/pm2-meteor/nova/adaV4-NOVA-EN/bundle/programs/server/npm/node_modules/regenerator-runtime/runtime.js:65:40)
at GeneratorFunctionPrototype.invoke [as _invoke] (/opt/pm2-meteor/nova/adaV4-NOVA-EN/bundle/programs/server/npm/node_modules/regen$
at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (/opt/pm2-meteor/nova/adaV4-NOVA-EN/bundle/programs/server/n$

Are your node versions on dev and deployment machines exactly the same?

node -v

You have triggered an unhandledRejection, you may have forgotten to catch a Promise rejection:
TypeError: The loader.load() function must be called with a value,but got: undefined.

regenerator runtime doesn’t pass a value and nova doesn’t handle the promise rejection, could be a version thing, could be something in the app.

I see that at least meteor 1.6.0.1 uses node 8.9.3 not 8.9.4… worth a try.

if you have nvm on your server it’s easier to keep this stuff precise…

Thank You vectorselector. Yes, my local and server use node 8.9.4. OK, will test with node 8.9.3 and let you know.

Same error with node 8.9.3 !

I’m going to guess that it’s this part that’s the problem:

Warning: fragment with name UsersCurrent already exists.
graphql-tag enforces all fragment names across your application to be unique; read more about
this in the docs: http://dev.apollodata.com/core/fragments.html#unique-names

Looks like when PM2 starts the app in cluster mode they all run the startup functions which causes a naming collision in Apollo?

I haven’t used Apollo/GraphQL so I can’t help any further than this.

Thank You coagmano. I will try to deploy without using the cluster mode !

Hi,

I am now able to deploy VulcanJS 1.8.5 with example-forum package by changing the setting in my pm2-meteor.json from:
“exec_mode”: “cluster_mode”,
to
"exec_mode": “fork_mode”,

It seems that the new requirement in Apollo that force the fragment name to be unique is not compatible with PM2 Cluster mode.

However, the deploy works only with fresh new database. Really need the migration script as mentioned by Sacha in his blog.

Thank You to all and in particular to coagmano that gave me the solution.

Adalidda