[英]Unexpected end of JSON input error in AWS Lambda SQS function
這是我的 nodejs 應用程序無服務器 lambda function
export const updateDailyForecastResults: SQSHandler = async (event) => {
console.log('Function invoked!!!!');
await env.check();
event.Records.forEach(record => {
const { body } = record;
console.log(body);
});
return;
};
我發送的是文檔示例 sqs 事件
{
"Records": [
{
"messageId": "059f36b4-87a3-44ab-83d2-661975830a7d",
"receiptHandle": "AQEBwJnKyrHigUMZj6rYigCgxlaS3SLy0a...",
"body": "test",
"attributes": {
"ApproximateReceiveCount": "1",
"SentTimestamp": "1545082649183",
"SenderId": "AIDAIENQZJOLO23YVJ4VO",
"ApproximateFirstReceiveTimestamp": "1545082649185"
},
"messageAttributes": {},
"md5OfBody": "098f6bcd4621d373cade4e832627b4f6",
"eventSource": "aws:sqs",
"eventSourceARN": "arn:aws:sqs:us-east-2:123456789012:my-queue",
"awsRegion": "us-east-2"
}
]
}
或者我嘗試了其他版本的 Json 對象,但總是遇到同樣的錯誤,即
{
"errorType": "Runtime.UserCodeSyntaxError",
"errorMessage": "SyntaxError: Unexpected end of JSON input",
"trace": [
"Runtime.UserCodeSyntaxError: SyntaxError: Unexpected end of JSON input",
" at _loadUserApp (/var/runtime/UserFunction.js:98:13)",
" at Object.module.exports.load (/var/runtime/UserFunction.js:140:17)",
" at Object.<anonymous> (/var/runtime/index.js:43:30)",
" at Module._compile (internal/modules/cjs/loader.js:1015:30)",
" at Object.Module._extensions..js (internal/modules/cjs/loader.js:1035:10)",
" at Module.load (internal/modules/cjs/loader.js:879:32)",
" at Function.Module._load (internal/modules/cjs/loader.js:724:14)",
" at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)",
" at internal/main/run_main_module.js:17:47"
]
}
請問有人可以幫我嗎?
此異常意味着您的代碼存在語法錯誤。
它發生在處理事件之前,所以你給它什么事件並不重要。
你能分享所有代碼(和依賴項)嗎?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.