我在 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"}'
}