Skip to content

Getting TypeError: Cannot use 'in' operator to search for 'status' in undefined when my Lambda@Edge handler uses callback(null, response) to return response #344

@joquijada

Description

@joquijada

When I use the Lambda@Edge handler callback(null, response) style of returning the response, I get the error below. It looks like the code is not aware of this style. See snippet farther below from src/services/cloudfront.service.ts. It's only passing event and context, but not a callback, return this.fnSet.originResponse(event, this.context);. Is this functionality that we'd want to add? If the answer is yes and I can carve out some time, I can take a look at submitting a PR for this issue. Thank you.

{"code":500,"message":"TypeError: Cannot use 'in' operator to search for 'status' in undefined\n    at Object.isResponseResult (/my-module/node_modules/serverless-offline-edge-lambda/dist/utils/is-response-result.js:5:21)\n    at CloudFrontLifecycle.<anonymous> (/my-module/node_modules/serverless-offline-edge-lambda/dist/services/cloudfront.service.js:100:25)\n    at Generator.next (<anonymous>)\n    at fulfilled (/my-module/node_modules/serverless-offline-edge-lambda/dist/services/cloudfront.service.js:5:58)\n    at processTicksAndRejections (internal/process/task_queues.js:95:5)"}* Closing connection 0
async onOriginResponse(result: CloudFrontResponseResult) {
		this.log('← origin-response');

		const event = combineResult(this.event, result);
		return this.fnSet.originResponse(event, this.context);
	}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions