-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
aws_logger handle is not closed while running jest tests. #291
Comments
From what I have seen this is still an issue with aws-crt, however I was able to mitigate by updating my aws-sdk clients to version 3.56.0 (@aws-sdk/client-lambda, @aws-sdk/client-s3) which updated theirs dependency on signature-v4-crt, which has subsequently removed its dep of this library. |
Can confirm that updating my
|
this is still a problem on aws-crt |
the aws sdk clients I use are at version 3.118.0 and aws-crt version 1.12.5 which are the latest available when I'm commenting and I still see this issue. UPDATE: I was able to resolve it by switching jest spies I had for sns client with a mock client using aws-sdk-client-mock |
I had a similar issue, and found a somewhat strange solution. It may not be the best solution but at least something that works. I had global code in a module doing something like this: import AWSXRay from 'aws-xray-sdk-core'
import { NodeHttpHandler } from '@aws-sdk/node-http-handler'
import { DynamoDBClient } from '@aws-sdk/client-dynamodb'
AWSXRay.setContextMissingStrategy('LOG_ERROR')
const client = new DynamoDBClient({
maxAttempts: 10,
requestHandler: new NodeHttpHandler({
connectionTimeout: 50,
socketTimeout: 50
})
})
// throw new Error("Oh no!") And if you uncomment the So, is there a way to prevent the execution of this code in tests? It turns there is. You need to do 2 things:
I hope it helps someone. I couldn't avoid the throwing until I used |
|
The logger handle is closed when the NAPI module is finalized by node. We don't have any control of when or if that happens; it seems to be a property of garbage collection. So on the surface, there's not much that can be done about the logger if we keep existing behavior. However, there is a possibility that instead of enabling the logging router (takes native logging and writes to the Javascript console api) by default, we could instead make it opt-in (by environment and/or API call). This is potentially a disruptive change and I'm unsure of all of the consequences of it yet but I don't see any other way forward with this issue. |
I am struggling with this same issue. I tried creating a mocks directory and adding a file to it named aws_logger.ts which exports a jest function
The in the test I call jest.mock()
But the warning is persisting... so I must be doing something incorrectly. Could you share some more information about how you managed to get jest to use the mocked node module? |
This is still an issue with SDK clients version 3.583.0, and aws-crt version 1.21.2. Any chance it might get fixed? |
The status of this is unchanged from my previous comment on the issue. |
While running jest for my nodejs tests, I am noticing that the "aws_logger" handle is not getting closed resulting in automation tests failing.
Jest has detected the following 1 open handle potentially keeping Jest from exiting:
● aws_logger
error Command failed with exit code 1.
The text was updated successfully, but these errors were encountered: