electerious / Ackee

Self-hosted, Node.js based analytics tool for those who care about privacy.
https://ackee.electerious.com
MIT License
4.27k stars 359 forks source link

Error when trying to login: FUNCTION_INVOCATION_FAILED #268

Closed Albermonte closed 3 years ago

Albermonte commented 3 years ago

🐞 Describe the bug

Trying to login to my account and this is displayed:

A server error has occurred

FUNCTION_INVOCATION_FAILED

Error: A server error has occurred

FUNCTION_INVOCATION_FAILED

    at Md (https://an.shortnim.me/index.js:83:13349)
    at async https://an.shortnim.me/index.js:83:13926

📚 To Reproduce

Deploy latest version to verce, wait a few days and this error showed

💡 Expected behavior

To login without any issue

⚙️ Environment

electerious commented 3 years ago

Can you find anything in the Vercel serverless function logs?

Albermonte commented 3 years ago

I was going to check it but now it's working without touching anything. I'll close this issue and re-open again if it happens again and will be posting the serverless logs.

Thanks

Albermonte commented 3 years ago

Here we go again...

[POST] /api
19:13:47:48
2021-06-23T17:13:51.565Z    ba9ccd58-3aa6-4e62-a631-0b9d25ded96c    ERROR   Unhandled Promise Rejection     {"errorType":"Runtime.UnhandledPromiseRejection","errorMessage":"MongoError: Authentication failed.","reason":{"errorType":"MongoError","errorMessage":"Authentication failed.","code":8000,"ok":0,"codeName":"AtlasError","name":"MongoError","stack":["MongoError: Authentication failed.","    at MessageStream.messageHandler (/var/task/node_modules/mongodb/lib/cmap/connection.js:268:20)","    at MessageStream.emit (events.js:376:20)","    at processIncomingData (/var/task/node_modules/mongodb/lib/cmap/message_stream.js:144:12)","    at MessageStream._write (/var/task/node_modules/mongodb/lib/cmap/message_stream.js:42:5)","    at writeOrBuffer (internal/streams/writable.js:358:12)","    at MessageStream.Writable.write (internal/streams/writable.js:303:10)","    at TLSSocket.ondata (internal/streams/readable.js:745:22)","    at TLSSocket.emit (events.js:376:20)","    at addChunk (internal/streams/readable.js:309:12)","    at readableAddChunk (internal/streams/readable.js:284:9)","    at TLSSocket.Readable.push (internal/streams/readable.js:223:10)","    at TLSWrap.onStreamRead (internal/stream_base_commons.js:188:23)"]},"promise":{},"stack":["Runtime.UnhandledPromiseRejection: MongoError: Authentication failed.","    at process.<anonymous> (/var/runtime/index.js:35:15)","    at process.emit (events.js:376:20)","    at processPromiseRejections (internal/process/promises.js:245:33)","    at processTicksAndRejections (internal/process/task_queues.js:96:32)"]}
Unknown application error occurred

I'm using MongoDB Atlas and I have been using it for a long time for other apps, and this is the first time I see this error :/

electerious commented 3 years ago

Hmm, hard to say if this is a problem of Ackee or MongoDB Atlas. I've never had this error on my installation and Ackee shouldn't have any problems to connect to a MongoDB. Does it happen all the time or just sometimes? Is there a connection limit or something when using MongoDB Atlas?

Albermonte commented 3 years ago

There was no problem with connection limit or anything at Atlas side.

I redeployed it manually instead of using the Deploy to Vercel button, also changed the MongoDB password to something without especial characters, I think this could be the problem but it was only happening sometimes so I have no idea why.

So far it's been working flawlessly, closing this issue until it happens again.

pixelass commented 3 years ago

Having the same issue. Should I open a new ticket?

It's a vanilla setup. Nothing has been touched. I just followed the guide.

A server error has occurred

FUNCTION_INVOCATION_FAILED

Error: A server error has occurred

FUNCTION_INVOCATION_FAILED

    at Md (https://ackee-roan.vercel.app/index.js:83:13349)
    at async https://ackee-roan.vercel.app/index.js:83:13926
[POST] /api
17:12:42:38
2021-07-24T15:12:42.450Z    7dd9dca6-c2dd-4959-9316-8d865e8a3e83    ERROR   Unhandled Promise Rejection     {"errorType":"Runtime.UnhandledPromiseRejection","errorMessage":"MongooseServerSelectionError: connect ECONNREFUSED 127.0.0.1:27017","reason":{"errorType":"MongooseServerSelectionError","errorMessage":"connect ECONNREFUSED 127.0.0.1:27017","message":"connect ECONNREFUSED 127.0.0.1:27017","reason":{"type":"Single","setName":null,"maxSetVersion":null,"maxElectionId":null,"servers":{},"stale":false,"compatible":true,"compatibilityError":null,"logicalSessionTimeoutMinutes":null,"heartbeatFrequencyMS":10000,"localThresholdMS":15,"commonWireVersion":null},"stack":["MongooseServerSelectionError: connect ECONNREFUSED 127.0.0.1:27017","    at NativeConnection.Connection.openUri (/var/task/node_modules/mongoose/lib/connection.js:839:32)","    at /var/task/node_modules/mongoose/lib/index.js:348:10","    at /var/task/node_modules/mongoose/lib/helpers/promiseOrCallback.js:31:5","    at new Promise (<anonymous>)","    at promiseOrCallback (/var/task/node_modules/mongoose/lib/helpers/promiseOrCallback.js:30:10)","    at Mongoose._promiseOrCallback (/var/task/node_modules/mongoose/lib/index.js:1149:10)","    at Mongoose.connect (/var/task/node_modules/mongoose/lib/index.js:347:20)","    at module.exports (/var/task/src/utils/connect.js:5:38)","    at Object.<anonymous> (/var/task/src/serverless.js:14:1)","    at Module._compile (internal/modules/cjs/loader.js:1085:14)","    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)","    at Module.load (internal/modules/cjs/loader.js:950:32)","    at Function.Module._load (internal/modules/cjs/loader.js:790:14)","    at Module.require (internal/modules/cjs/loader.js:974:19)","    at require (internal/modules/cjs/helpers.js:92:18)","    at Object.<anonymous> (/var/task/api/index.js:12:19)"]},"promise":{},"stack":["Runtime.UnhandledPromiseRejection: MongooseServerSelectionError: connect ECONNREFUSED 127.0.0.1:27017","    at process.<anonymous> (/var/runtime/index.js:35:15)","    at process.emit (events.js:375:28)","    at processPromiseRejections (internal/process/promises.js:245:33)","    at processTicksAndRejections (internal/process/task_queues.js:96:32)","    at runNextTicks (internal/process/task_queues.js:64:3)","    at processTimers (internal/timers.js:497:9)"]}
[ERROR] [1627139562452] LAMBDA_RUNTIME Failed to post handler success response. Http response code: 400.
RequestId: 24c3d488-330b-494f-93a5-620ff1f85fba Error: Runtime exited with error: exit status 128
Runtime.ExitError
electerious commented 3 years ago

@pixelass Thanks for letting me know. I'm not sure why this happens. I would like to help, but Vercel sometimes fails to run the function for no obvious reason. The function itself is fine and runs in all my tests.

flashclub commented 2 years ago

There was no problem with connection limit or anything at Atlas side.

I redeployed it manually instead of using the Deploy to Vercel button, also changed the MongoDB password to something without especial characters, I think this could be the problem but it was only happening sometimes so I have no idea why.

So far it's been working flawlessly, closing this issue until it happens again.

Thank you very much, I keep getting this error when logging in. Then I changed the '.' in the password when the problem was solved.

I don't understand why this error occurs when mongodb password has '.' .