jesec/flood

Crash on startup with latest Docker (master)

Elegant996 opened this issue · 33 comments

Type: Bug Report

  • Try to follow the update procedure described in the README and try again before opening this issue.

Your Environment

  • Version used:
    jesec/flood:master-distroless from Docker as of December 7th 2023.

Summary

Docker image fails to launch with the following: TypeError: Cannot read properties of undefined (reading 'push')

Expected Behavior

Flood should start.

Current Behavior

Flood does not start.

Possible Solution

Steps to Reproduce

  1. Use jesec/flood:master-distroless from Docker
  2. Access web UI
  3. Observe container crashes

Context

Use Flood.

trim21 commented

can you try latest image and paste full stack trace here?I can't re-produce.

Perhaps its because I'm not serving assets? I'm running a web server to serve the assets which has been working great until this last push. That error is literally all that appears before the container crashes:

Flood server 0.0.0-master.fc1e90d starting on https://10.244.5.200:3000



Starting without builtin authentication



Static assets not served



FATAL internal error. Please open an issue.

Uncaught exception: TypeError: Cannot read properties of undefined (reading 'push')

Please note that I have pulled the latest static assets from the latest docker image. I mount the assets directory from the image into the web server container. Same image ID.

My setup always pulls the latest image on startup.

Thanks!

trim21 commented

can you paste your full docker run command or compose config file?

Not running with any extra Docker commands (using K8s) these are the env's though:

FLOOD_OPTION_ALLOWEDPATH: "/mnt"
FLOOD_OPTION_ASSETS: "false"
FLOOD_OPTION_AUTH: "none"
FLOOD_OPTION_BASEURI: "/"
FLOOD_OPTION_HOST: *uses container IP*
FLOOD_OPTION_RTSOCKET: "/run/rtorrent/rtorrent.sock"
FLOOD_OPTION_RUNDIR: "/flood/data"
FLOOD_OPTION_SSL: "true"
FLOOD_OPTION_SSLCERT: "/tls/tls.crt"
FLOOD_OPTION_SSLKEY: "/tls/tls.key"
trim21 commented

Ok, I'll take a look

trim21 commented

I still can not re-produce...

trim21 commented

can you try latest image which will print error's stack trace?

Flood server 0.0.0-master.f42009f starting on https://10.244.5.250:3000

Starting without builtin authentication

Static assets not served

FATAL internal error. Please open an issue.
Uncaught exception: TypeError: Cannot read properties of undefined (reading 'push')
stack trace: TypeError: Cannot read properties of undefined (reading 'push')
    at ServerResponse._writeRaw (node:_http_outgoing:376:19)
    at ServerResponse._send (node:_http_outgoing:349:15)
    at ServerResponse.end (node:_http_outgoing:961:10)
    at /snapshot/flood/dist/index.js
    at g (/snapshot/flood/dist/index.js)
    at handleError (/snapshot/flood/dist/index.js)
    at X (/snapshot/flood/dist/index.js)
    at r.send (/snapshot/flood/dist/index.js)
    at ee (/snapshot/flood/dist/index.js)
    at s (/snapshot/flood/dist/index.js)
Stream closed EOF for media/rtorrent-0 (flood)

Sorry, stepped out for the evening. Double-checked asset locations for webserver, still correct and using this same image for those assets.

trim21 commented

I still can't find out reason…

does flood without any option works?

trim21 commented

please try latest image and paste stack trace again

No log; just fails to start the container now. Instant crash.

trim21 commented

zero log at all?

trim21 commented

sorry, I still can't re-produce this, I'm using docker-compose.

Interesting! I had a TCP health-check on port 3000 and the recent changes for testing somehow delayed the TCP health-check longer than my threshold permitted so K8s decided to kill the pod. I've disabled health-checks and got the log:

Flood server 0.0.0-master.be22e24 starting on https://10.244.5.187:3000

Starting without builtin authentication

Static assets not served

FATAL internal error. Please open an issue.
Uncaught exception: TypeError: Cannot read properties of undefined (reading 'push')
stack trace: TypeError: Cannot read properties of undefined (reading 'push')
    at ServerResponse._writeRaw (node:_http_outgoing:376:19)
    at ServerResponse._send (node:_http_outgoing:349:15)
    at ServerResponse.end (node:_http_outgoing:961:10)
    at s (webpack://jesec/flood/webpack/startup:4:71)
    at s (webpack://jesec/flood/webpack/startup:4:71)
    at s (webpack://jesec/flood/webpack/startup:4:71)
    at s (webpack://jesec/flood/webpack/startup:4:71)
    at s (webpack://jesec/flood/webpack/startup:4:71)
    at s (webpack://jesec/flood/webpack/startup:4:71)
    at s (webpack://jesec/flood/webpack/startup:4:71)
Stream closed EOF for media/rtorrent-0 (flood)
trim21 commented

can you try jesec/flood:master-dbg image?stack trace from jesec/flood:master-distroless is unexpectedly useless…

Now we're getting somewhere:

> flood@0.0.0-master.eaefd4c start:development:server
> NODE_ENV=development tsx watch server/bin/start.ts --host=0.0.0.0

npm ERR! code EACCES
npm ERR! syscall mkdir
npm ERR! path /.npm
npm ERR! errno -13
npm ERR! 
npm ERR! Your cache folder contains root-owned files, due to a bug in
npm ERR! previous versions of npm which has since been addressed.
npm ERR! 
npm ERR! To permanently fix this problem, please run:
npm ERR!   sudo chown -R 201615:201615 "/.npm"

npm ERR! Log files were not written due to an error writing to the directory: /.npm/_logs
npm ERR! You can rerun the command with `--loglevel=verbose` to see the logs in your terminal
Stream closed EOF for media/rtorrent-0 (flood)

Try running as non-root? 😄 201615 is the user and group since this uses sys for the NFS mounts and that ID has sufficient access.

trim21 commented

I'm guessing this is a different problem, dbg image run flood with npm and run process with different user.

How did you mount volume in your container?

Mounting an emptyDir for the flood rundir and another one for the rtsocket. Regular directories for rtorrent are under /mnt which should not impact anything.

trim21 commented

Then I have no idea...

You are trying this as well where assets are not served and a webserver is being run? This worked fine until the other day... It's definitely related to the latest commits...

trim21 commented

Yes, I use same options with docker-compose and still can't re-produce it.

I guess this is caused by #661, but you can't run start dbg image as expected so I can't debug it...

Ah, well then let's try as root :)


> flood@0.0.0-master.eaefd4c start:development:server
> NODE_ENV=development tsx watch server/bin/start.ts --host=0.0.0.0

(node:36) ExperimentalWarning: `--experimental-loader` may be removed in the future; instead use `register()`:
--import 'data:text/javascript,import { register } from "node:module"; import { pathToFileURL } from "node:url"; register("file%3A///usr/src/app/node_modules/tsx/dist/loader.js", pathToFileURL("./"));'
(Use `node --trace-warnings ...` to show where the warning was created)
Stream closed EOF for media/rtorrent-0 (flood)
trim21 commented

Ah, well then let's try as root :)


> flood@0.0.0-master.eaefd4c start:development:server
> NODE_ENV=development tsx watch server/bin/start.ts --host=0.0.0.0

(node:36) ExperimentalWarning: `--experimental-loader` may be removed in the future; instead use `register()`:
--import 'data:text/javascript,import { register } from "node:module"; import { pathToFileURL } from "node:url"; register("file%3A///usr/src/app/node_modules/tsx/dist/loader.js", pathToFileURL("./"));'
(Use `node --trace-warnings ...` to show where the warning was created)
Stream closed EOF for media/rtorrent-0 (flood)

Looks like this container doesn't exit?

Yeah, I didn't edit my config properly so another probe killed it early. The master-dbg appears to run without issue if I run it as root. I tried running distroless as root but the issue remained. Trying to see if there's another way to uncover what is happening...

trim21 commented

I'll try fix source map in distroless image

trim21 commented

please try latest distroless image again, stack trace should work now.

Same errors but I realized something. If dbg works and the errors don't occur with npm, there's a good chance that the issue is actually related to the env's being used. After some deeper diving, these caused the issue:

FLOOD_OPTION_SSL: "true"
FLOOD_OPTION_SSLCERT: "/tls/tls.crt"
FLOOD_OPTION_SSLKEY: "/tls/tls.key"

Perhaps it's how those settings are being pushed?

trim21 commented

please paste stack trace…

trim21 commented

Same errors but I realized something. If dbg works and the errors don't occur with npm, there's a good chance that the issue is actually related to the env's being used. After some deeper diving, these caused the issue:

FLOOD_OPTION_SSL: "true"
FLOOD_OPTION_SSLCERT: "/tls/tls.crt"
FLOOD_OPTION_SSLKEY: "/tls/tls.key"

Perhaps it's how those settings are being pushed?

can you share your key and crt file?I have a ssl cert but didn't reproduce this issue.

Yep, it's regenerated on container creation though. I'm not overly familiar with js but I was wondering if this line is somehow forcing SSL to be false?

trim21 commented

It mean ssl is disabled by defualt

trim21 commented

OK, I can reproduce now, it need a http request to trigger this issue.

trim21 commented

OK, this bug is caused by @fastify/express not supporting http2, I would just disable http2 and everything should works fine