Skip to content

Runtime error after update from 1.5.0 to 2.0.4 #34

Closed
@NLueg

Description

@NLueg

Hi there, we recently tried to update to 2.0.4. TypeScript is actually happy about the changes but we receive an issue during runtime:

TypeError: Cannot read properties of undefined (reading 'clientCredentials')
    at getClientCredentials (C:\Users\NICLUEG\GitHub\customer-search-service\src\vehicle\vehicle-kdm\vehicle-kdm.service.ts:13:35)
    at VehicleKdmService.getKdmInfo (C:\Users\NICLUEG\GitHub\customer-search-service\src\vehicle\vehicle-kdm\vehicle-kdm.service.ts:54:17) 
    at VehicleKdmController.getKdmInfo (C:\Users\NICLUEG\GitHub\customer-search-service\src\vehicle\vehicle-kdm\vehicle-kdm-controller.ts:22:24)
    at C:\Users\NICLUEG\GitHub\customer-search-service\node_modules\@nestjs\core\router\router-execution-context.js:38:29
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at C:\Users\NICLUEG\GitHub\customer-search-service\node_modules\@nestjs\core\router\router-execution-context.js:46:28
    at C:\Users\NICLUEG\GitHub\customer-search-service\node_modules\@nestjs\core\router\router-proxy.js:9:17

We use this code for retrieving the clientCredentials:

import oauth from 'axios-oauth-client';
import * as axios from 'axios';

async function getClientCredentials() {
  Logger.debug('trying to get credentials');
  const tokenResult = await oauth.clientCredentials(
    axios.default.create(),
    process.env.OAUTH_URL,
    process.env.OAUTH_CLIENTID,
    process.env.OAUTH_CLIENTSECRET
  )('');
  return tokenResult;
}

This is our TSConfig:

{
  "compilerOptions": {
    "skipLibCheck": true,
    "module": "commonjs",
    "declaration": true,
    "removeComments": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "target": "ES2021",
    "sourceMap": true,
    "outDir": "./dist",
    "baseUrl": "./",
    "resolveJsonModule": true
  },
  "exclude": ["node_modules", "dist"],
  "rules": {
    "quotemark": [true, "single", "avoid-escape"]
  }
}

Do you have an idea what could be the issue?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions