Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/batch/src/AsyncBatchProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class AsyncBatchProcessor extends BasePartialBatchProcessor {
): Promise<SuccessResponse | FailureResponse> {
try {
const data = this.toBatchType(record, this.eventType);
const result = await this.handler(data, this.options);
const result = await this.handler(data, this.options?.context);

return this.successHandler(record, result);
} catch (error) {
Expand Down
2 changes: 1 addition & 1 deletion packages/batch/src/BatchProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class BatchProcessor extends BasePartialBatchProcessor {
public processRecord(record: BaseRecord): SuccessResponse | FailureResponse {
try {
const data = this.toBatchType(record, this.eventType);
const result = this.handler(data, this.options);
const result = this.handler(data, this.options?.context);

return this.successHandler(record, result);
} catch (error) {
Expand Down
13 changes: 3 additions & 10 deletions packages/batch/tests/helpers/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type {
KinesisStreamRecord,
SQSRecord,
} from 'aws-lambda';
import type { BatchProcessingOptions } from '../../src/types';
import type { Context } from 'aws-lambda';

const sqsRecordHandler = (record: SQSRecord): string => {
const body = record.body;
Expand Down Expand Up @@ -63,12 +63,7 @@ const asyncDynamodbRecordHandler = async (
return body;
};

const handlerWithContext = (
record: SQSRecord,
options: BatchProcessingOptions
): string => {
const context = options.context;

const handlerWithContext = (record: SQSRecord, context: Context): string => {
try {
if (context.getRemainingTimeInMillis() == 0) {
throw Error('No time remaining.');
Expand All @@ -82,10 +77,8 @@ const handlerWithContext = (

const asyncHandlerWithContext = async (
record: SQSRecord,
options: BatchProcessingOptions
context: Context
): Promise<string> => {
const context = options.context;

try {
if (context.getRemainingTimeInMillis() == 0) {
throw Error('No time remaining.');
Expand Down