You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We're running our local parse server in AWS Singapore. We're using mLab in US for our Database. Since there is a latency involved, for some of the queries we receive timeout. We're currently working on improving the slow queries by building some indexes. And we wanted to give a response from the parse-server if a specific timeout has reached.
For eg:
We're running parse-server using express. We're using connect-timeout for checking the timeout for a request.
Let us say if a timeout of 10 secs has been reached, we would like to send a response with the status code 408 and response as below
{"message": "Request timedout!"}
We were trying to achieve with the following code, but couldn't able to do since we don't have a callback from the parse-server
Could you guys please suggest some ways for us?
varport=process.env.PORT||1337;varmountPath=process.env.PARSE_MOUNT||'/parse';varparseConfiguration={databaseURI: process.env.DATABASE_URI||'mongodb://localhost:27017/dev',cloud: process.env.CLOUD_CODE_MAIN||__dirname+'/cloud/main.js',appId: process.env.APP_ID,masterKey: process.env.MASTER_KEY,//Add your master key here. Keep it secret!serverURL: process.env.SERVER_URL||'http://localhost:'+port+mountPath,// Don't forget to change to https if needed,push: {android: {senderId: process.env.GCM_SENDER_ID,apiKey: process.env.GCM_API_KEY}},publicServerURL: process.env.PUBLIC_SERVER_URL,emailAdapter: SimpleSendGridAdapter({apiKey: process.env.SENDGRID_API_KEY,fromAddress: process.env.SENDGRID_EMAIL_FROM})};if(process.env.LOG_LEVEL){parseConfiguration.logLevel=process.env.LOG_LEVEL;}varparseApi=newParseServer(parseConfiguration);varapp=express();app.use(mountPath,timeout('10s'),(req,res,next)=>{req.on("timeout",function(evt){if(req.timedout){if(!res.headersSent){res.status(408).send({message: 'Request timedout!'});}}});parseApi(req,res,next);});
And I guess since node works on event driven approach we can't avoid the CPU, memory usages. But at least we wanted to avoid the Error: Can't set headers after they are sent in the logs, since we're listening for timeout event and sending the response
We would like to have some timeout option in the parse configuration or some work around if parse-server is able to give the callback. Or may be there is a better way.
The text was updated successfully, but these errors were encountered:
swami701
changed the title
Callback or response from the parse-server in case of mongo timeout or any long processing
Callback or response from the parse-server in case of mongo DB or any long processing timeout
Nov 26, 2016
It's not clear to me if this should be an issue. Is there something actionable that can be done by opening a PR? Or are you looking to start a discussion? For the latter, I suggest using Serverfault or Stack Overflow, as we're not using GitHub issues for general Q&A.
Environment Setup
Server
Database
We're running our local parse server in AWS Singapore. We're using mLab in US for our Database. Since there is a latency involved, for some of the queries we receive timeout. We're currently working on improving the slow queries by building some indexes. And we wanted to give a response from the parse-server if a specific timeout has reached.
For eg:
We're running parse-server using express. We're using connect-timeout for checking the timeout for a request.
Let us say if a timeout of
10 secs
has been reached, we would like to send a response with the status code408
and response as belowWe were trying to achieve with the following code, but couldn't able to do since we don't have a callback from the parse-server
Could you guys please suggest some ways for us?
And I guess since node works on event driven approach we can't avoid the CPU, memory usages. But at least we wanted to avoid the
Error: Can't set headers after they are sent
in the logs, since we're listening for timeout event and sending the responseWe would like to have some timeout option in the parse configuration or some work around if parse-server is able to give the callback. Or may be there is a better way.
Thank you very much.
The text was updated successfully, but these errors were encountered: