# Tips and FAQs

This page contains troubleshooting tips and FAQs for CDK.

## Logging requests and responses

You can use `console.log` statement in the handler to log requests and responses:

```typescript
export const getTopRatedMoviesHandler = OperationHandlerSetup.configureHandler<
  TmdbAuth,
  GetTopRatedMoviesInput,
  GetTopRatedMoviesOutput
>((handler) =>
  handler.withGlobalConfiguration(globalConfigHttp).usingHttp((http) =>
    http
      .get("/3/movie/top_rated")
      .handleRequest((_ctx, _input, request) => \{
        console.log(request.withoutBody());
        return request.withoutBody();
      \})
      .handleResponse((_ctx, _input, response) => \{
        console.log(response.parseWithBodyAsJson());
        return response.parseWithBodyAsJson();
      \})
  )
);
```

You can also log responses in the handler.test files:

```typescript
OperationHandlerTestSetup.configureHandlerTest(
  getTopRatedMoviesHandler,
  (handlerTest) =>
    handlerTest
      .usingHandlerContext("test")
      .nothingBeforeAll()
      .testCase("should return 20 movies", (testCase) =>
        testCase
          .givenNothing()
          .when(() => ({}))
          .then(({ output }) => \{
            const outputValue =
              OperationHandlerResult.getSuccessfulValueOrFail(output);
            console.log(outputValue);
            expect(outputValue.results.length).toEqual(20);
          \})
          .finallyDoNothing()
      )
      .nothingAfterAll()
);
```

## Request Timeouts

Your tests may time out if the 3rd party service API is taking longer than 5 seconds to respond.

This is because the testing library for CDK: `jest` has a [default timeout](https://jestjs.io/docs/configuration#testtimeout-number) of 5 seconds for each test.

To increase timeout for a particular operation, simply add `jest.setTimeout(<timeout value in milliseconds>)` to your `handler.test.ts` file. e.g.

```typescript
jest.setTimeout(30000); //30000 milliseconds
```

You can increase timeout for all of your tests by setting `testTimeout` property in `jest.config.json` file. e.g. `"testTimeout": 30000` where 30000 is the timeout in milliseconds.

## Deployment errors

You may encounter the below error while deploying the connector:

```cli
Error (500): \{"message":"ENOTEMPTY: directory not empty, rmdir './tmp/connectors/cloudscale-Dubber/node_modules/@types/node'","\_tag":"InternalError"\}
```

To solve this, simpley delete `node_modules` folder and perform a reinstall using `npm i`
