[GH-ISSUE #3321] [bug]: Segmentation fault / Crashing Container when starting hoppscotch ce backend docker image on k8s #1104

Closed
opened 2026-03-16 18:34:32 +03:00 by kerem · 12 comments
Owner

Originally created by @RaHehl on GitHub (Sep 6, 2023).
Original GitHub issue: https://github.com/hoppscotch/hoppscotch/issues/3321

Originally assigned to: @balub on GitHub.

Is there an existing issue for this?

  • I have searched the existing issues

Current behavior

We are trying to move from our self-made images based on Webysther's PR to the new Docker hoppscotch/hoppscotch-backend:2023.8.0 image.

But our API container crashes with a segfault:

segfa

Steps to reproduce

use hoppscotch/hoppscotch-backend:2023.8.0

Environment

Production

Version

Self-hosted

Originally created by @RaHehl on GitHub (Sep 6, 2023). Original GitHub issue: https://github.com/hoppscotch/hoppscotch/issues/3321 Originally assigned to: @balub on GitHub. ### Is there an existing issue for this? - [X] I have searched the existing issues ### Current behavior We are trying to move from our self-made images based on Webysther's PR to the new Docker hoppscotch/hoppscotch-backend:2023.8.0 image. But our API container crashes with a segfault: ![segfa](https://github.com/hoppscotch/hoppscotch/assets/7577984/20bd83d9-c9d2-4fb1-b48c-8b583ea10905) ### Steps to reproduce use hoppscotch/hoppscotch-backend:2023.8.0 ### Environment Production ### Version Self-hosted
kerem 2026-03-16 18:34:32 +03:00
Author
Owner

@henrysachs commented on GitHub (Sep 6, 2023):

we were previously using the custom docker container mentioned a lot here in other issues. When taking a look into the old container logs we se that after pub sub normally:

Initialize PubSub
[Nest] 1110  - 09/06/2023, 2:34:56 PM     LOG [GraphQLModule] Mapped {/graphql, POST} route +243ms

graphql seems to boot. So I think there are some issues with the built container and the containing graphql library. Maybe a postinstall script or something like that.

<!-- gh-comment-id:1708500941 --> @henrysachs commented on GitHub (Sep 6, 2023): we were previously using the custom docker container mentioned a lot here in other issues. When taking a look into the old container logs we se that after pub sub normally: ``` Initialize PubSub [Nest] 1110 - 09/06/2023, 2:34:56 PM LOG [GraphQLModule] Mapped {/graphql, POST} route +243ms ``` graphql seems to boot. So I think there are some issues with the built container and the containing graphql library. Maybe a postinstall script or something like that.
Author
Owner

@AndrewBastin commented on GitHub (Sep 6, 2023):

@henrysachs does this happen with hoppscotch/hoppscotch:2023.8.0 ?

<!-- gh-comment-id:1708583716 --> @AndrewBastin commented on GitHub (Sep 6, 2023): @henrysachs does this happen with `hoppscotch/hoppscotch:2023.8.0` ?
Author
Owner

@henrysachs commented on GitHub (Sep 6, 2023):

Yes

<!-- gh-comment-id:1708595909 --> @henrysachs commented on GitHub (Sep 6, 2023): Yes
Author
Owner

@AndrewBastin commented on GitHub (Sep 6, 2023):

We are unable to reproduce this on our end directly, so can we get some info on your environment and your k8s setup so we can try to repro it on our end ?

<!-- gh-comment-id:1708630429 --> @AndrewBastin commented on GitHub (Sep 6, 2023): We are unable to reproduce this on our end directly, so can we get some info on your environment and your k8s setup so we can try to repro it on our end ?
Author
Owner

@henrysachs commented on GitHub (Sep 6, 2023):

its eks 1.23 with x86 nodes. We are deploying the independent containers. we also set a lot of environment variables but i think we cant provide all of them. Not sure what Info we can provide additionally. We are using helm to deploy.

<!-- gh-comment-id:1708633884 --> @henrysachs commented on GitHub (Sep 6, 2023): its eks 1.23 with x86 nodes. We are deploying the independent containers. we also set a lot of environment variables but i think we cant provide all of them. Not sure what Info we can provide additionally. We are using helm to deploy.
Author
Owner

@RaHehl commented on GitHub (Sep 7, 2023):

@AndrewBastin We got more information by loading the node coredump:

image

What reminded us that we had adapted the mailer module (packages/hoppscotch-backend/src/mailer/mailer.module.ts) in our custom build, to ignore ssl problems.

image

<!-- gh-comment-id:1709675360 --> @RaHehl commented on GitHub (Sep 7, 2023): @AndrewBastin We got more information by loading the node coredump: ![image](https://github.com/hoppscotch/hoppscotch/assets/7577984/3695e2fd-25af-43b2-9bc4-2c5054efd929) What reminded us that we had adapted the mailer module (packages/hoppscotch-backend/src/mailer/mailer.module.ts) in our custom build, to ignore ssl problems. ![image](https://github.com/hoppscotch/hoppscotch/assets/7577984/39b16d42-7d1c-4f75-8743-d07f613c1db3)
Author
Owner

@henrysachs commented on GitHub (Sep 7, 2023):

so the fix seems to be upgrading the base docker image from alpine 3.16 to alpine 3.18

<!-- gh-comment-id:1709859895 --> @henrysachs commented on GitHub (Sep 7, 2023): so the fix seems to be upgrading the base docker image from alpine 3.16 to alpine 3.18
Author
Owner

@henrysachs commented on GitHub (Sep 7, 2023):

these were our changes to make it work. Would you be open that we contribute this? :)

diff --git a/packages/hoppscotch-backend/src/mailer/mailer.module.ts b/packages/hoppscotch-backend/src/mailer/mailer.module.ts
index f24aa5d6..3c2c24ee 100644
--- a/packages/hoppscotch-backend/src/mailer/mailer.module.ts
+++ b/packages/hoppscotch-backend/src/mailer/mailer.module.ts
@@ -1,27 +1,36 @@
-import { Module } from '@nestjs/common';
 import { MailerModule as NestMailerModule } from '@nestjs-modules/mailer';
 import { HandlebarsAdapter } from '@nestjs-modules/mailer/dist/adapters/handlebars.adapter';
-import { MailerService } from './mailer.service';
+import { Module } from '@nestjs/common';
+import { MAILER_FROM_ADDRESS_UNDEFINED } from 'src/errors';
 import { throwErr } from 'src/utils';
-import {
-  MAILER_FROM_ADDRESS_UNDEFINED,
-  MAILER_SMTP_URL_UNDEFINED,
-} from 'src/errors';
+import { MailerService } from './mailer.service';

 @Module({
   imports: [
-    NestMailerModule.forRoot({
-      transport:
-        process.env.MAILER_SMTP_URL ?? throwErr(MAILER_SMTP_URL_UNDEFINED),
-      defaults: {
-        from:
-          process.env.MAILER_ADDRESS_FROM ??
-          throwErr(MAILER_FROM_ADDRESS_UNDEFINED),
-      },
-      template: {
-        dir: __dirname + '/templates',
-        adapter: new HandlebarsAdapter(),
-      },
+    NestMailerModule.forRootAsync({
+      useFactory: () => ({
+        transport: {
+          host: process.env.SMTP_DOMAIN,
+          port: 587,
+          secure: false, // upgrade later with STARTTLS
+          auth: {
+            user: process.env.SMTP_USER,
+            pass: process.env.SMTP_PASSWORD,
+          },
+          tls: {
+            rejectUnauthorized: false,
+          },
+        },
+        defaults: {
+          from:
+            process.env.MAILER_ADDRESS_FROM ??
+            throwErr(MAILER_FROM_ADDRESS_UNDEFINED),
+        },
+        template: {
+          dir: __dirname + '/templates',
+          adapter: new HandlebarsAdapter(),
+        },
+      }),
     }),
   ],
   providers: [MailerService],
diff --git a/prod.Dockerfile b/prod.Dockerfile
index 28cbab31..f5f571f1 100644
--- a/prod.Dockerfile
+++ b/prod.Dockerfile
@@ -1,4 +1,4 @@
-FROM node:18-alpine3.16 as base_builder
+FROM node:18-alpine3.18 as base_builder

 WORKDIR /usr/src/app
<!-- gh-comment-id:1709892966 --> @henrysachs commented on GitHub (Sep 7, 2023): these were our changes to make it work. Would you be open that we contribute this? :) ```diff diff --git a/packages/hoppscotch-backend/src/mailer/mailer.module.ts b/packages/hoppscotch-backend/src/mailer/mailer.module.ts index f24aa5d6..3c2c24ee 100644 --- a/packages/hoppscotch-backend/src/mailer/mailer.module.ts +++ b/packages/hoppscotch-backend/src/mailer/mailer.module.ts @@ -1,27 +1,36 @@ -import { Module } from '@nestjs/common'; import { MailerModule as NestMailerModule } from '@nestjs-modules/mailer'; import { HandlebarsAdapter } from '@nestjs-modules/mailer/dist/adapters/handlebars.adapter'; -import { MailerService } from './mailer.service'; +import { Module } from '@nestjs/common'; +import { MAILER_FROM_ADDRESS_UNDEFINED } from 'src/errors'; import { throwErr } from 'src/utils'; -import { - MAILER_FROM_ADDRESS_UNDEFINED, - MAILER_SMTP_URL_UNDEFINED, -} from 'src/errors'; +import { MailerService } from './mailer.service'; @Module({ imports: [ - NestMailerModule.forRoot({ - transport: - process.env.MAILER_SMTP_URL ?? throwErr(MAILER_SMTP_URL_UNDEFINED), - defaults: { - from: - process.env.MAILER_ADDRESS_FROM ?? - throwErr(MAILER_FROM_ADDRESS_UNDEFINED), - }, - template: { - dir: __dirname + '/templates', - adapter: new HandlebarsAdapter(), - }, + NestMailerModule.forRootAsync({ + useFactory: () => ({ + transport: { + host: process.env.SMTP_DOMAIN, + port: 587, + secure: false, // upgrade later with STARTTLS + auth: { + user: process.env.SMTP_USER, + pass: process.env.SMTP_PASSWORD, + }, + tls: { + rejectUnauthorized: false, + }, + }, + defaults: { + from: + process.env.MAILER_ADDRESS_FROM ?? + throwErr(MAILER_FROM_ADDRESS_UNDEFINED), + }, + template: { + dir: __dirname + '/templates', + adapter: new HandlebarsAdapter(), + }, + }), }), ], providers: [MailerService], diff --git a/prod.Dockerfile b/prod.Dockerfile index 28cbab31..f5f571f1 100644 --- a/prod.Dockerfile +++ b/prod.Dockerfile @@ -1,4 +1,4 @@ -FROM node:18-alpine3.16 as base_builder +FROM node:18-alpine3.18 as base_builder WORKDIR /usr/src/app ```
Author
Owner

@AndrewBastin commented on GitHub (Sep 7, 2023):

@henrysachs thanks for the diff, we will look into this and verify the fixes, you can open up a PR for this. (cc: @balub, please verify segfaults that happen w.r.t Prisma).

The whole reason for the downgrade to Alpine 3.16 was because there is a weird sorta transition happening between the OpenSSL versions and how Node/native handle them. The updated OpenSSL version (v3) had lead us to have issues with Prisma crashing with a similar set of problems when the backend processes certain queries, which is why it is pinned down. Alpine 3.16 gives OpenSSL 1.1 on its repositories.

These issues (with OpenSSL) are seemed to be fixed in Node 20+ but since the LTS is still 18, we are waiting for the next LTS to hopefully clear these all up.

<!-- gh-comment-id:1709923727 --> @AndrewBastin commented on GitHub (Sep 7, 2023): @henrysachs thanks for the diff, we will look into this and verify the fixes, you can open up a PR for this. (cc: @balub, please verify segfaults that happen w.r.t Prisma). The whole reason for the downgrade to Alpine 3.16 was because there is a weird sorta transition happening between the OpenSSL versions and how Node/native handle them. The updated OpenSSL version (v3) had lead us to have issues with Prisma crashing with a similar set of problems when the backend processes certain queries, which is why it is pinned down. Alpine 3.16 gives OpenSSL 1.1 on its repositories. These issues (with OpenSSL) are seemed to be fixed in Node 20+ but since the LTS is still 18, we are waiting for the next LTS to hopefully clear these all up.
Author
Owner

@AprilNEA commented on GitHub (Sep 14, 2023):

Same problem happened, hopefully it will be resolved soon.

<!-- gh-comment-id:1719812626 --> @AprilNEA commented on GitHub (Sep 14, 2023): Same problem happened, hopefully it will be resolved soon.
Author
Owner

@jordibeen commented on GitHub (Oct 2, 2023):

Having the same issue while trying to run it on Kubernetes, hoping the above mentioned fix will be rolled out soon!

<!-- gh-comment-id:1742623524 --> @jordibeen commented on GitHub (Oct 2, 2023): Having the same issue while trying to run it on Kubernetes, hoping the above mentioned fix will be rolled out soon!
Author
Owner

@RaHehl commented on GitHub (Nov 21, 2023):

@AndrewBastin looks like 20 is now LTS? https://nodejs.org/en

<!-- gh-comment-id:1820559062 --> @RaHehl commented on GitHub (Nov 21, 2023): @AndrewBastin looks like 20 is now LTS? https://nodejs.org/en
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/hoppscotch#1104
No description provided.