unnbound-events 1.0.3 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/client.js +33 -5
- package/package.json +1 -1
package/dist/lib/client.js
CHANGED
|
@@ -202,6 +202,14 @@ function createEventsClient() {
|
|
|
202
202
|
}
|
|
203
203
|
const region = options?.region || env.AWS_REGION || 'us-east-1';
|
|
204
204
|
const endpoint = env.AWS_SQS_ENDPOINT || env.AWS_ENDPOINT_URL || undefined;
|
|
205
|
+
// Log SQS configuration for debugging
|
|
206
|
+
unnbound_logger_sdk_1.logger.info({
|
|
207
|
+
queueUrl: queueUrl.replace(/\/[^/]+$/, '/***'), // Mask queue name for security
|
|
208
|
+
region,
|
|
209
|
+
endpoint,
|
|
210
|
+
hasCredentials: !!(env.AWS_ACCESS_KEY_ID || env.AWS_CONTAINER_CREDENTIALS_RELATIVE_URI),
|
|
211
|
+
executionEnv: env.AWS_EXECUTION_ENV,
|
|
212
|
+
}, 'Starting SQS listener');
|
|
205
213
|
const waitTimeSeconds = options?.waitTimeSeconds ?? 10;
|
|
206
214
|
const maxMessages = options?.maxMessages ?? 10;
|
|
207
215
|
const visibilityTimeout = options?.visibilityTimeoutSeconds;
|
|
@@ -247,11 +255,31 @@ function createEventsClient() {
|
|
|
247
255
|
// Start async loop without awaiting
|
|
248
256
|
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
249
257
|
loop();
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
258
|
+
// Test the SQS connection immediately to catch early errors
|
|
259
|
+
return new Promise((resolve, reject) => {
|
|
260
|
+
const testConnection = async () => {
|
|
261
|
+
try {
|
|
262
|
+
const testParams = {
|
|
263
|
+
QueueUrl: queueUrl,
|
|
264
|
+
MaxNumberOfMessages: 1,
|
|
265
|
+
WaitTimeSeconds: 0, // Don't wait, just test connection
|
|
266
|
+
};
|
|
267
|
+
await sqs.send(new awsSqs.ReceiveMessageCommand(testParams));
|
|
268
|
+
unnbound_logger_sdk_1.logger.info('SQS connection test successful');
|
|
269
|
+
resolve({
|
|
270
|
+
stop() {
|
|
271
|
+
stopped = true;
|
|
272
|
+
return Promise.resolve();
|
|
273
|
+
},
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
catch (error) {
|
|
277
|
+
unnbound_logger_sdk_1.logger.error({ err: error, queueUrl: queueUrl.replace(/\/[^/]+$/, '/***') }, 'SQS connection test failed');
|
|
278
|
+
reject(error instanceof Error ? error : new Error(String(error)));
|
|
279
|
+
}
|
|
280
|
+
};
|
|
281
|
+
// Run connection test after a short delay to allow the async loop to start
|
|
282
|
+
setTimeout(testConnection, 100);
|
|
255
283
|
});
|
|
256
284
|
},
|
|
257
285
|
async start(options) {
|
package/package.json
CHANGED