我在netlify上编写了一个Node.JS lambda函数,该函数在Firestore中创建了一个文档。调用该功能时,文档已添加到Firestore中,但问题是netlify函数未返回响应且该函数未停止(在netlify dev
中出错)。
我的代码如下:
exports.handler = () => {
db.collection('collection')
.add(object)
.then(() => {
return JSON.stringify({ success: true });
})
.catch((err) => {
return JSON.stringify({ error: err });
});
};
我的netlify dev
日志是:
◈ Netlify Dev ◈
◈ Adding the following env variables from .env: API_KEY,AUTH_DOMAIN,DATABASE_URL,PROJECT_ID,STORAGE_BUCKET,MESSAGING_SENDER_ID,APP_ID,EMAIL,PASSWORD
◈ No app server detected and no "command" specified
◈ Using current working directory
◈ Unable to determine public folder to serve files from
◈ Setup a netlify.toml file with a [dev] section to specify your dev server settings.
◈ See docs at: https://cli.netlify.com/netlify-dev#project-detection
◈ Running static server from "something.com"
◈ Functions server is listening on 58955
◈ Server listening to 3999
┌─────────────────────────────────────────────────┐
│ │
│ ◈ Server now ready on http://localhost:8888 │
│ │
└─────────────────────────────────────────────────┘
Request from ::1: GET /.netlify/functions/funcname
{"level":"error","message":"End - Error:"}
{"errorMessage":"Task timed out after 10.00 seconds","errorType":"TimeoutError","stackTrace":["new TimeoutError (C:\\Users\\Vaibhav\\AppData\\Local\\Yarn\\Data\\global\\node_modules\\lambda-local\\build\\lib\\utils.js:110:28)","Context.<anonymous> (C:\\Users\\Vaibhav\\AppData\\Local\\Yarn\\Data\\global\\node_modules\\lambda-local\\build\\lib\\context.js:110:19)","listOnTimeout (internal/timers.js:554:17)","processTimers (internal/timers.js:497:7)"],"level":"error"}
Response with status 500 in 10917 ms.
◈ Error during invocation: {
errorMessage: 'Task timed out after 10.00 seconds',
errorType: 'TimeoutError',
stackTrace: [
'new TimeoutError (C:\\Users\\Vaibhav\\AppData\\Local\\Yarn\\Data\\global\\node_modules\\lambda-local\\build\\lib\\utils.js:110:28)',
'Context.<anonymous> (C:\\Users\\Vaibhav\\AppData\\Local\\Yarn\\Data\\global\\node_modules\\lambda-local\\build\\lib\\context.js:110:19)',
'listOnTimeout (internal/timers.js:554:17)',
'processTimers (internal/timers.js:497:7)'
],
level: 'error',
[Symbol(level)]: 'error',
[Symbol(message)]: '{"errorMessage":"Task timed out after 10.00 seconds","errorType":"TimeoutError","stackTrace":["new TimeoutError (C:\\\\Users\\\\Vaibhav\\\\AppData\\\\Local\\\\Yarn\\\\Data\\\\global\\\\node_modules\\\\lambda-local\\\\build\\\\lib\\\\utils.js:110:28)","Context.<anonymous> (C:\\\\Users\\\\Vaibhav\\\\AppData\\\\Local\\\\Yarn\\\\Data\\\\global\\\\node_modules\\\\lambda-local\\\\build\\\\lib\\\\context.js:110:19)","listOnTimeout (internal/timers.js:554:17)","processTimers (internal/timers.js:497:7)"],"level":"error"}'
}
答案 0 :(得分:0)
您将收到500码状态,这意味着服务器出现内部错误。在开发人员模式下,您会有一个响应,因为请求完成后会有10秒钟的时间。可能是请求或参数出现问题。