Timeout in Authentication Methods inside Docker
Closed this issue · 3 comments
Package version
@adonisjs/auth@9.0.0 | MIT | deps: 2 | versions: 77
Describe the bug
Dear Community,
We are experiencing an unusual issue during the deployment of an AdonisJS application in a Kubernetes environment. We've observed that any method requiring authentication does not respond in our project, and this issue only occurs within the Docker Image.
We conducted tests in various scenarios, where the application worked successfully, including:
- Deploying the project on Debian.
- Deploying the project on Ubuntu.
However, both authentication and subsequent authorizations fail entirely in a pod environment, unlike in local, Mac, and other environments.
We suspect that some library might be using an OS-native function not available in both bitnami/minideb and 5.4.253-167.359.amzn2.x86_64.
There are no explicit errors; the system simply fails to respond. We also noticed a slight increase in CPU usage on the server with each attempt.
We created a project from scratch following the exact tutorial. In the controller, the error persists. When the method "auth.attempt" is called, the project stalls at this point.
Has anyone encountered this issue? I am available to provide more information and conduct any tests that might help.
Additional useful information:
FROM bitnami/minideb AS base
RUN install_packages wget ca-certificates tar
RUN cd /tmp && \
wget https://nodejs.org/dist/v16.13.1/node-v16.13.1-linux-x64.tar.gz -O node.tar.gz && \
tar -zxvf node.tar.gz -C /usr/local --strip-components=1 && \
rm -f node.tar.gz
RUN mkdir -p /app
WORKDIR /app
RUN mkdir tmp
FROM base AS dependencies
COPY ./package.json ./
RUN npm ci
COPY . .
FROM dependencies AS build
RUN node ace build --production
FROM base AS production
COPY ./package.json ./
COPY ./prisma ./prisma
COPY ./newrelic.js ./newrelic.js
RUN npm ci --production
COPY --from=build /app/build .
EXPOSE $PORT
CMD [ "npm", "run", "prisma"]
CMD [ "node", "-r", "newrelic", "server.js" ]
Just to clarify: the problem only occurs when using Docker.
The project was also tested on domestic computers running Ubuntu, Windows, and Mac, and in all these scenarios, it functioned correctly.
We find this behavior quite strange. We have investigated and found nothing that could trigger this issue, which is why we decided to create this issue.
Thank you for your assistance.
Reproduction repo
No response
With the information you have provided I am hardly tell or do anything. Also, if you are using AdonisJS v5, then you are using the incorrect version of @adonisjs/auth
.
The @adonisjs/auth@9.0
targets the v6 of the framework core. Please downgrade the version to @adonisjs/auth@8.2.3
.
If that does not work. Then please share a repo to help us reproduce the issue. This repo should not be your entire project, it should be a small app that isolates the issue you are talking about
Thank you for the package information, I just performed the downgrade, but the result is the same.
I uploaded the repository here: https://github.com/toolzzlabzz/example-auth-timeout/tree/main
I removed all the external business logic and omitted a lot of things, it serves just as an example of the execution.
The original implementation was: controller -> service -> usecase -> output.
I did another test, within Cleavr, and it worked perfectly, reinforcing my hypothesis that some native OS resource is used, and not available in both node-alpine and minidab.
Thank you very much for your support! We look forward to the launch of the Adonis 6 support program."
We discovered the problem; it was not related to the Auth package, but rather to the Redis connector.
Although the status was Healthy, it did not establish a stable connection with the AWS ElasticCache Redis service due to the TLS property.
We reverted to a previous version of the AdonisJS Redis package (we were on version 8.0.0 LTS), along with a new deployment with an earlier version of Redis in which only the use of the "TLS" flag in config/redis.ts had a positive effect.
Thank you for the prompt support!