Skip to content

Commit 7abcaa6

Browse files
committed
add diagnostics on import error
1 parent f66a440 commit 7abcaa6

File tree

7 files changed

+25
-15
lines changed

7 files changed

+25
-15
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file.
55

66
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
77

8+
9+
## [0.1.19] 2023-08-06
10+
11+
- Improve diagnostics on import error
812
## [0.1.18] 2023-07-24
913

1014
- Improved robustness of callback support
File renamed without changes.

multi-region-deploy.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,13 @@ if (!stage) {
1111
}
1212

1313
function deployToRegion(region: string) {
14-
const result = execSync(`npm run deploy -- --stage ${stage} --region ${region}`)
15-
console.log(result.toString())
14+
try {
15+
const result = execSync(`npm run deploy -- --stage ${stage} --region ${region}`)
16+
console.log(result.toString())
17+
} catch(error) {
18+
console.log(error)
19+
}
20+
1621
}
1722

1823
async function addLayerToChangeLog() {

multiRegion.json

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,6 @@
11
{
22
"regions": [
3-
"eu-west-2",
4-
"eu-west-1",
5-
"us-east-1",
6-
"us-east-2",
7-
"us-west-2",
8-
"eu-central-1",
9-
"ap-south-1",
10-
"ap-southeast-1",
11-
"ap-southeast-2",
12-
"ap-northeast-1",
13-
"ca-central-1"
3+
"us-west-1"
144
],
155
"output": "md"
166
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@baselime/lambda-node-opentelemetry",
3-
"version": "0.1.18",
3+
"version": "0.1.19",
44
"description": "OpenTelemetry auto tracer for Node.JS based AWS Lambda functions",
55
"keywords": [
66
"nodejs",

src/loader.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ async function _tryImport(path:string) {
44
try {
55
return await import(path);
66
} catch(err) {
7+
console.error(err)
78
return false;
89
}
910
}
@@ -12,6 +13,7 @@ function _tryRequire(path: string) {
1213
try {
1314
return require(path);
1415
} catch(err) {
16+
console.error(err)
1517
return false;
1618
}
1719
}
@@ -24,7 +26,7 @@ export async function load(taskRoot: string, originalHandler: string) {
2426
const functionName = pathDetails.ext.slice(1);
2527

2628
const functionPath = path.resolve(taskRoot, pathDetails.dir, pathDetails.name);
27-
29+
2830
const lambda = await _tryImport(functionPath + '.js') || await _tryImport(functionPath + '.mjs')
2931

3032
if (!lambda) {

tests/load.test.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,13 @@ describe('load()', () => {
1111
expect(handler).toBeInstanceOf(Function);
1212

1313
})
14+
15+
it('should load with no path', async () => {
16+
const taskRoot = path.resolve(__dirname, 'data');
17+
const originalHandler = 'index.main';
18+
19+
const handler = await load(taskRoot, originalHandler);
20+
expect(handler).toBeInstanceOf(Function);
21+
22+
})
1423
});

0 commit comments

Comments
 (0)