Skip to content

Commit d02f5b2

Browse files
committed
Apply @godu feedbacks on #89
1 parent 0fead9f commit d02f5b2

File tree

1 file changed

+12
-16
lines changed
  • packages/serverless-offline-kinesis/src

1 file changed

+12
-16
lines changed

packages/serverless-offline-kinesis/src/index.js

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const functionHelper = require('serverless-offline/src/functionHelper');
2626
const LambdaContext = require('serverless-offline/src/LambdaContext');
2727

2828
const NO_KINESIS_FOUND = 'Could not find kinesis stream';
29-
const KINESIS_RETRY_DELAY = 2000;
29+
const KINESIS_RETRY_DELAY = 200;
3030

3131
const printBlankLine = () => console.log();
3232

@@ -160,22 +160,18 @@ class ServerlessOfflineKinesis {
160160
.catch(err => err);
161161

162162
if (kinesisStream instanceof Error) {
163-
if (retry) {
164-
this.serverless.cli.log(
165-
`${streamName} - not found because of ${
166-
kinesisStream.code
167-
}, retrying in ${KINESIS_RETRY_DELAY}ms`
168-
);
169-
setTimeout(
170-
this.createKinesisReadable.bind(this),
171-
KINESIS_RETRY_DELAY,
172-
functionName,
173-
streamEvent,
174-
retry
175-
);
176-
return;
177-
} else throw new Error(NO_KINESIS_FOUND);
163+
if (!retry) throw new Error(NO_KINESIS_FOUND);
164+
165+
this.serverless.cli.log(
166+
`${streamName} - not found because of ${
167+
kinesisStream.code
168+
}, retrying in ${KINESIS_RETRY_DELAY}ms`
169+
);
170+
return setTimeout(() => {
171+
this.createKinesisReadable(functionName, streamEvent, retry);
172+
}, KINESIS_RETRY_DELAY);
178173
}
174+
179175
const {
180176
StreamDescription: {Shards: shards}
181177
} = kinesisStream;

0 commit comments

Comments
 (0)