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.
Files changed (2) hide show
  1. package/dist/lib/client.js +33 -5
  2. package/package.json +1 -1
@@ -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
- return Promise.resolve({
251
- stop() {
252
- stopped = true;
253
- return Promise.resolve();
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
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "unnbound-events",
3
3
  "description": "Unified events SDK to handle HTTP routes and SQS messages with a single routing API.",
4
- "version": "1.0.3",
4
+ "version": "1.0.4",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "scripts": {