RangeError: Maximum call stack size exceeded

See original GitHub issue

Bug Report

Hi All,

When I try to retrieve image from one URL and sending the response. I am getting the following error.

controller.file.ts

@Get("/:id/photo")
 @Header("Content-Type", "image/png")
 @ApiResponse({ status: HttpStatus.OK, description: "Get user photo" })
 @ApiResponse({ status: HttpStatus.NOT_FOUND, description: "Not found" })
 @ApiParam({ name: "id" })
 async getUserPhoto(@Param() parameter, @Res() response): Promise<any> {
   const result = await this.userService.getUserPhoto(parameter.id);
   return result.data.pipe(response);
 }

service.file.ts

 async getUserPhoto(userId: string): Promise<AxiosResponse> {
    try {
      const URL = "https://example.com";
      return await this.httpService.axiosRef({
        url: `${URL }/photo/{userId}`,
        method: "GET",
        responseType: "stream",
      });
    } catch (error) {
      throw new HttpException("Image Not Found", HttpStatus.NOT_FOUND);
    }
  }

This code was worked with @nest/common - 6.8.3

I updated to @nest/common - 6.11.1 and getting the following error.

Error

RangeError: Maximum call stack size exceeded at baseClone (path\node_modules\lodash.clonedeep\index.js:841:19)
Error [ERR_STREAM_WRITE_AFTER_END]: write after end
    at write_ (_http_outgoing.js:632:17)
    at ServerResponse.write (_http_outgoing.js:624:15)
    at IncomingMessage.ondata (_stream_readable.js:753:22)
    at IncomingMessage.emit (events.js:219:5)
    at IncomingMessage.EventEmitter.emit (domain.js:482:12)
    at IncomingMessage.Readable.read (_stream_readable.js:553:10)
    at flow (_stream_readable.js:1022:34)
    at resume_ (_stream_readable.js:1003:3)
    at processTicksAndRejections (internal/process/task_queues.js:84:21)

Please help me to solve this.

Thanks.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
jmcdo29commented, Apr 3, 2021

@btd1337 that looks to be related to nestjs-config which is a community module, not managed by the core team

0reactions
btd1337commented, Apr 3, 2021

Nest.js version: 7.6.15

// src/app.module

@Module({
    imports: [WinstonModule.forRoot(winstonConfig) ]
})
// winston.config
export const winstonConfig: WinstonModuleOptions = {
	levels: winston.config.npm.levels,
	level: 'verbose',
	transports: [
		new winston.transports.Console({
			format: winston.format.combine(
				winston.format.timestamp(),
				nestWinstonModuleUtilities.format.nestLike(),
			),
		}),
		new winston.transports.File({
			level: 'verbose',
			filename: 'application.log',
			dirname: 'logs',
		}),
	],
};

If winstonConfig is inside src/config this error occur:

[Nest] 96   - 04/03/2021, 4:18:41 AM   [ExceptionHandler] Maximum call stack size exceeded +2152ms
RangeError: Maximum call stack size exceeded
    at decorated.bindCustomHelpers (/home/node/app/node_modules/nestjs-config/dist/module/config.service.js:237:22)
    at /home/node/app/node_modules/nestjs-config/dist/module/config.service.js:246:46
    at Array.reduce (<anonymous>)
    at decorated.bindCustomHelpers (/home/node/app/node_modules/nestjs-config/dist/module/config.service.js:238:36)
    at /home/node/app/node_modules/nestjs-config/dist/module/config.service.js:246:46
    at Array.reduce (<anonymous>)
    at decorated.bindCustomHelpers (/home/node/app/node_modules/nestjs-config/dist/module/config.service.js:238:36)
    at /home/node/app/node_modules/nestjs-config/dist/module/config.service.js:246:46
    at Array.reduce (<anonymous>)
    at decorated.bindCustomHelpers (/home/node/app/node_modules/nestjs-config/dist/module/config.service.js:238:36)
[nodemon] app crashed - waiting for file changes before starting...

But if winstonConfig is inside any other folder in src the project is compiled normally.

Read more comments on GitHub >

github_iconTop Results From Across the Web

javascript - Maximum call stack size exceeded error
It means that somewhere in your code, you are calling a function which in turn calls another function and so forth, until you...
Read more >
JavaScript Error: Maximum Call Stack Size Exceeded
If you see the “Maximum Call Stack Size Exceeded” error, there's likely a problem with a recursive function within your JavaScript code.
Read more >
RangeError: Maximum call stack size exceeded - Educative.io
The most common source for this error is infinite recursion. You must have a recursive function in your code whose base case is...
Read more >
Uncaught RangeError: Maximum call ... - Net-Informations.Com
This error is almost always means you have a problem with recursion in JavaScript code, as there isn't any other way in JavaScript...
Read more >
How to fix: "RangeError: Maximum call stack size exceeded"
A "RangeError: Maximum call stack size exceeded" is an error that occurs when a function or operation tries to execute too many nested...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found