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
6 changes: 3 additions & 3 deletions packages/commons/src/Utility.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
* To learn more about the Lambda execution environment lifecycle, see the [Execution environment section](https://docs.aws.amazon.com/lambda/latest/dg/runtimes-context.html) of the AWS Lambda documentation.
*
* As a Powertools for AWS Lambda (TypeScript) user you probably won't be using this class directly, in fact if you use other Powertools for AWS utilities the cold start heuristic found here is already used to:
* * Add a `coldStart` key to the structured logs when injecting context information in `Logger`
* * Emit a metric during a cold start function invocation in `Metrics`
* * Annotate the invocation segment with a `coldStart` key in `Tracer`
* - Add a `coldStart` key to the structured logs when injecting context information in `Logger`
* - Emit a metric during a cold start function invocation in `Metrics`
* - Annotate the invocation segment with a `coldStart` key in `Tracer`
*
* If you want to use this logic in your own utilities, `Utility` provides two methods:
*
Expand Down
2 changes: 1 addition & 1 deletion packages/commons/src/envUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ const getNumberFromEnv = ({
const parsedValue = Number(value);

if (Number.isNaN(parsedValue)) {
throw new Error(`Environment variable ${key} must be a number`);
throw new TypeError(`Environment variable ${key} must be a number`);
}

return parsedValue;
Expand Down
6 changes: 3 additions & 3 deletions packages/commons/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { PT_VERSION } from './version.js';

const env = process.env.AWS_EXECUTION_ENV || 'NA';
if (!process.env.AWS_SDK_UA_APP_ID) {
process.env.AWS_SDK_UA_APP_ID = `PT/NO-OP/${PT_VERSION}/PTEnv/${env}`;
} else {
if (process.env.AWS_SDK_UA_APP_ID) {
process.env.AWS_SDK_UA_APP_ID = `${process.env.AWS_SDK_UA_APP_ID}/PT/NO-OP/${PT_VERSION}/PTEnv/${env}`;
} else {
process.env.AWS_SDK_UA_APP_ID = `PT/NO-OP/${PT_VERSION}/PTEnv/${env}`;
}

export { addUserAgentMiddleware, isSdkClient } from './awsSdkUtils.js';
Expand Down
3 changes: 2 additions & 1 deletion packages/commons/tests/types/LambdaInterface.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@ describe('Type: LambdaInterface', () => {
expectTypeOf(lambda.handler).toBeFunction();
});

it('works with an async handler', async () => {
it('works with an async handler', () => {
// Prepare
class Lambda implements LambdaInterface {
public async handler(_event: unknown, context: Context) {
context.getRemainingTimeInMillis();
await new Promise((r) => setTimeout(r, 1));
return 'Hello World';
}
}
Expand Down
4 changes: 2 additions & 2 deletions packages/commons/tests/unit/awsSdkUtils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ describe('Helpers: awsSdk', () => {
expect(console.warn).toHaveBeenCalledTimes(1);
});

it('should return and do nothing if the client already has a Powertools UA middleware', async () => {
it('should return and do nothing if the client already has a Powertools UA middleware', () => {
// Prepare
const client = {
middlewareStack: {
Expand All @@ -51,7 +51,7 @@ describe('Helpers: awsSdk', () => {
expect(client.middlewareStack.addRelativeTo).toHaveBeenCalledTimes(0);
});

it('should call the function to add the middleware with the correct arguments', async () => {
it('should call the function to add the middleware with the correct arguments', () => {
// Prepare
const client = {
middlewareStack: {
Expand Down
Loading