smogon / pokemon-showdown

Pokémon battle simulator.
https://pokemonshowdown.com
MIT License
4.77k stars 2.79k forks source link

Can't get showdown to run in Docker anymore #8824

Closed BUCKFAE closed 2 years ago

BUCKFAE commented 2 years ago

Hey! I've been playing around with this awesome project for quite some time now but as of today, my Dockerfile stopped working:

FROM ubuntu:latest

RUN apt update
RUN apt-get install git nodejs npm -y

# Cloning showdown
WORKDIR /root/
RUN git clone https://github.com/smogon/pokemon-showdown.git
WORKDIR /root/pokemon-showdown

# Setup
RUN npm install
RUN cp -r config/config-example.js config/config.js

Running showdown inside the container yields the following error:

root@4aa9438aae86:~/pokemon-showdown# ./pokemon-showdown start --no-securtity
RESTORE CHATROOM: lobby
RESTORE CHATROOM: staff

CRASH: Error: read ECONNRESET
    at Pipe.onStreamRead (node:internal/stream_base_commons:217:20)
    at Pipe.callbackTrampoline (node:internal/async_hooks:130:17)

CRASH: Error: read ECONNRESET
    at Pipe.onStreamRead (node:internal/stream_base_commons:217:20)
    at Pipe.callbackTrampoline (node:internal/async_hooks:130:17)

CRASH: Error: read ECONNRESET
    at Pipe.onStreamRead (node:internal/stream_base_commons:217:20)
    at Pipe.callbackTrampoline (node:internal/async_hooks:130:17)

CRASH: TypeError: Cannot read properties of undefined (reading 'encoding')
    at NetStream.push (/root/pokemon-showdown/lib/streams.ts:123:61)
    at IncomingMessage.<anonymous> (/root/pokemon-showdown/lib/net.ts:99:10)
    at IncomingMessage.emit (node:events:537:28)
    at IncomingMessage.emit (node:domain:482:12)
    at IncomingMessage.Readable.read (node:internal/streams/readable:539:10)
    at flow (node:internal/streams/readable:1023:34)
    at resume_ (node:internal/streams/readable:1004:3)
    at processTicksAndRejections (node:internal/process/task_queues:82:21)

CRASH: TypeError: Cannot read properties of undefined (reading 'encoding')
    at NetStream.push (/root/pokemon-showdown/lib/streams.ts:123:61)
    at IncomingMessage.<anonymous> (/root/pokemon-showdown/lib/net.ts:99:10)
    at IncomingMessage.emit (node:events:537:28)
    at IncomingMessage.emit (node:domain:482:12)
    at addChunk (node:internal/streams/readable:324:12)
    at readableAddChunk (node:internal/streams/readable:293:11)
    at IncomingMessage.Readable.push (node:internal/streams/readable:234:10)
    at HTTPParser.parserOnBody (node:_http_common:130:24)
    at TLSSocket.socketOnData (node:_http_client:505:22)
    at TLSSocket.emit (node:events:537:28)

CRASH: TypeError: Cannot read properties of undefined (reading 'encoding')
    at NetStream.push (/root/pokemon-showdown/lib/streams.ts:123:61)
    at IncomingMessage.<anonymous> (/root/pokemon-showdown/lib/net.ts:99:10)
    at IncomingMessage.emit (node:events:537:28)
    at IncomingMessage.emit (node:domain:482:12)
    at IncomingMessage.Readable.read (node:internal/streams/readable:539:10)
    at flow (node:internal/streams/readable:1023:34)
    at resume_ (node:internal/streams/readable:1004:3)
    at processTicksAndRejections (node:internal/process/task_queues:82:21)

Worker 1 now listening on 0.0.0.0:8000
Test your server at http://localhost:8000

CRASH: TypeError: Cannot read properties of undefined (reading 'encoding')
    at NetStream.push (/root/pokemon-showdown/lib/streams.ts:123:61)
    at IncomingMessage.<anonymous> (/root/pokemon-showdown/lib/net.ts:99:10)
    at IncomingMessage.emit (node:events:537:28)
    at IncomingMessage.emit (node:domain:482:12)
    at IncomingMessage.Readable.read (node:internal/streams/readable:539:10)
    at flow (node:internal/streams/readable:1023:34)
    at resume_ (node:internal/streams/readable:1004:3)
    at processTicksAndRejections (node:internal/process/task_queues:82:21)

CRASH: TypeError: Cannot read properties of undefined (reading 'encoding')
    at NetStream.push (/root/pokemon-showdown/lib/streams.ts:123:61)
    at IncomingMessage.<anonymous> (/root/pokemon-showdown/lib/net.ts:99:10)
    at IncomingMessage.emit (node:events:537:28)
    at IncomingMessage.emit (node:domain:482:12)
    at addChunk (node:internal/streams/readable:324:12)
    at readableAddChunk (node:internal/streams/readable:293:11)
    at IncomingMessage.Readable.push (node:internal/streams/readable:234:10)
    at HTTPParser.parserOnBody (node:_http_common:130:24)
    at TLSSocket.socketOnData (node:_http_client:505:22)
    at TLSSocket.emit (node:events:537:28)

For setup, I followed the instructions at server/README.md

The same issue occurs when I run the project without docker (the error message is identical).

Node on my local machine:

(pokemon) ➜  pokemon-showdown git:(master) node --version
v18.4.0
(pokemon) ➜  pokemon-showdown git:(master) npm --version
8.12.1

I tried this both on my MacBook as well as on my Linux machine. Same results.

BUCKFAE commented 2 years ago

Update:

New Dockerfile:

FROM ubuntu:latest

RUN apt update
RUN apt-get install git nodejs npm curl vim -y

# Cloning showdown
WORKDIR /root/
RUN git clone https://github.com/smogon/pokemon-showdown.git
WORKDIR /root/pokemon-showdown

# Forcing exact version
RUN sed -i 's/\^//g' package.json

RUN cp -r config/config-example.js config/config.js

# Correct node version
RUN npm install -g n
RUN n 14.18.2

# Setup
RUN npm install

Now the server works until I open localhost:8000 to connect to the Server. Then it crashes like this:

RESTORE CHATROOM: lobby
RESTORE CHATROOM: staff
Worker 1 now listening on 0.0.0.0:8000
Test your server at http://localhost:8000

CRASH: TypeError: Cannot set property roomSettings of #<Object> which has only a getter
    at Object.loadPlugin (/root/pokemon-showdown/server/chat.ts:1993:64)
    at Object.loadPluginFile (/root/pokemon-showdown/server/chat.ts:1916:8)
    at Object.loadPluginDirectory (/root/pokemon-showdown/server/chat.ts:1928:11)
    at Object.loadPlugins (/root/pokemon-showdown/server/chat.ts:2042:8)
    at Object.parse (/root/pokemon-showdown/server/chat.ts:1867:8)
    at User.chat (/root/pokemon-showdown/server/users.ts:1414:9)
    at Object.socketReceive (/root/pokemon-showdown/server/users.ts:1686:12)
    at Object.onSpawn (/root/pokemon-showdown/server/sockets.ts:53:11)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)

CRASH: TypeError: Cannot set property roomSettings of #<Object> which has only a getter
    at Object.loadPlugin (/root/pokemon-showdown/server/chat.ts:1993:64)
    at Object.loadPluginFile (/root/pokemon-showdown/server/chat.ts:1916:8)
    at Object.loadPluginDirectory (/root/pokemon-showdown/server/chat.ts:1928:11)
    at Object.loadPlugins (/root/pokemon-showdown/server/chat.ts:2042:8)
    at Object.parse (/root/pokemon-showdown/server/chat.ts:1867:8)
    at User.chat (/root/pokemon-showdown/server/users.ts:1414:9)
    at Object.socketReceive (/root/pokemon-showdown/server/users.ts:1686:12)
    at Object.onSpawn (/root/pokemon-showdown/server/sockets.ts:53:11)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)

CRASH: TypeError: Cannot set property roomSettings of #<Object> which has only a getter
    at Object.loadPlugin (/root/pokemon-showdown/server/chat.ts:1993:64)
    at Object.loadPluginFile (/root/pokemon-showdown/server/chat.ts:1916:8)
    at Object.loadPluginDirectory (/root/pokemon-showdown/server/chat.ts:1928:11)
    at Object.loadPlugins (/root/pokemon-showdown/server/chat.ts:2042:8)
    at Object.parse (/root/pokemon-showdown/server/chat.ts:1867:8)
    at User.chat (/root/pokemon-showdown/server/users.ts:1414:9)
    at Object.socketReceive (/root/pokemon-showdown/server/users.ts:1686:12)
    at Object.onSpawn (/root/pokemon-showdown/server/sockets.ts:53:11)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)

CRASH: TypeError: Cannot set property roomSettings of #<Object> which has only a getter
    at Object.loadPlugin (/root/pokemon-showdown/server/chat.ts:1993:64)
    at Object.loadPluginFile (/root/pokemon-showdown/server/chat.ts:1916:8)
    at Object.loadPluginDirectory (/root/pokemon-showdown/server/chat.ts:1928:11)
    at Object.loadPlugins (/root/pokemon-showdown/server/chat.ts:2042:8)
    at Object.parse (/root/pokemon-showdown/server/chat.ts:1867:8)
    at User.chat (/root/pokemon-showdown/server/users.ts:1414:9)
    at Object.socketReceive (/root/pokemon-showdown/server/users.ts:1686:12)
    at Object.onSpawn (/root/pokemon-showdown/server/sockets.ts:53:11)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)

CRASH: TypeError: Cannot set property roomSettings of #<Object> which has only a getter
    at Object.loadPlugin (/root/pokemon-showdown/server/chat.ts:1993:64)
    at Object.loadPluginFile (/root/pokemon-showdown/server/chat.ts:1916:8)
    at Object.loadPluginDirectory (/root/pokemon-showdown/server/chat.ts:1928:11)
    at Object.loadPlugins (/root/pokemon-showdown/server/chat.ts:2042:8)
    at Object.parse (/root/pokemon-showdown/server/chat.ts:1867:8)
    at User.chat (/root/pokemon-showdown/server/users.ts:1414:9)
    at Object.socketReceive (/root/pokemon-showdown/server/users.ts:1686:12)
    at Object.onSpawn (/root/pokemon-showdown/server/sockets.ts:53:11)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)

I looked at the respective files but I am unable to fix this myself.

BUCKFAE commented 2 years ago

Additional Info:

I found an old copy of the showdown folder, not running in a Docker container on my server. Starting and Connecting to it using ./pokemon-showdown start --no-security worked just as expected. After that, I used git pull to get the latest version. After that, starting still worked as expected.

I then removed the node_modules folder and ran npm install again. After that, showdown crashed again as shown above. I suspect that this is caused by a random dependency? I assume that this is also the reason why the pipeline is currently broken?

BUCKFAE commented 2 years ago

I believe that this was fixed in 1c756b111747fceee58fe0572bc3e229015e3588.

Here is my working Dockerfile:

FROM ubuntu:latest

RUN apt update
RUN apt-get install git nodejs npm curl vim -y

# Cloning showdown
WORKDIR /root/
RUN git clone https://github.com/smogon/pokemon-showdown.git
WORKDIR /root/pokemon-showdown

# Setting up config
RUN cp -r config/config-example.js config/config.js

# Changing to correct node version
RUN npm install -g n
RUN n 14.18.2

# Setup
RUN npm install

RUN n latest does not work for me, I have to explicitly use RUN n 14.18.2. This might be helpful to include in the server/README.md (#8826)

Bromancelot commented 1 year ago

I am having this EXACT issue, and have no idea how to get around it.

CRASH: TypeError: Cannot set property roomSettings of # which has only a getter at Object.loadPlugin (C:\Users\Public\SGT-Showdown\server\chat.ts:1971:64) at Object.loadPluginFile (C:\Users\Public\SGT-Showdown\server\chat.ts:1894:8) at Object.loadPluginDirectory (C:\Users\Public\SGT-Showdown\server\chat.ts:1906:11) at Object.loadPlugins (C:\Users\Public\SGT-Showdown\server\chat.ts:2020:8) at Object.parse (C:\Users\Public\SGT-Showdown\server\chat.ts:1845:8) at User.chat (C:\Users\Public\SGT-Showdown\server\users.ts:1414:9) at Object.socketReceive (C:\Users\Public\SGT-Showdown\server\users.ts:1686:12) at Object.onSpawn (C:\Users\Public\SGT-Showdown\server\sockets.ts:53:11) at processTicksAndRejections (node:internal/process/task_queues:96:5

BUCKFAE commented 1 year ago

I am having this EXACT issue, and have no idea how to get around it.

CRASH: TypeError: Cannot set property roomSettings of # which has only a getter at Object.loadPlugin (C:\Users\Public\SGT-Showdown\server\chat.ts:1971:64) at Object.loadPluginFile (C:\Users\Public\SGT-Showdown\server\chat.ts:1894:8) at Object.loadPluginDirectory (C:\Users\Public\SGT-Showdown\server\chat.ts:1906:11) at Object.loadPlugins (C:\Users\Public\SGT-Showdown\server\chat.ts:2020:8) at Object.parse (C:\Users\Public\SGT-Showdown\server\chat.ts:1845:8) at User.chat (C:\Users\Public\SGT-Showdown\server\users.ts:1414:9) at Object.socketReceive (C:\Users\Public\SGT-Showdown\server\users.ts:1686:12) at Object.onSpawn (C:\Users\Public\SGT-Showdown\server\sockets.ts:53:11) at processTicksAndRejections (node:internal/process/task_queues:96:5

I believe that this was fixed in 1c756b1.

Here is my working Dockerfile:

FROM ubuntu:latest

RUN apt update
RUN apt-get install git nodejs npm curl vim -y

# Cloning showdown
WORKDIR /root/
RUN git clone https://github.com/smogon/pokemon-showdown.git
WORKDIR /root/pokemon-showdown

# Setting up config
RUN cp -r config/config-example.js config/config.js

# Changing to correct node version
RUN npm install -g n
RUN n 14.18.2

# Setup
RUN npm install

RUN n latest does not work for me, I have to explicitly use RUN n 14.18.2. This might be helpful to include in the server/README.md (#8826)

Did you try this dockerfile? It works perfectly fine for me.

Bromancelot commented 1 year ago

I am having this EXACT issue, and have no idea how to get around it.

CRASH: TypeError: Cannot set property roomSettings of # which has only a getter at Object.loadPlugin (C:\Users\Public\SGT-Showdown\server\chat.ts:1971:64) at Object.loadPluginFile (C:\Users\Public\SGT-Showdown\server\chat.ts:1894:8) at Object.loadPluginDirectory (C:\Users\Public\SGT-Showdown\server\chat.ts:1906:11) at Object.loadPlugins (C:\Users\Public\SGT-Showdown\server\chat.ts:2020:8) at Object.parse (C:\Users\Public\SGT-Showdown\server\chat.ts:1845:8) at User.chat (C:\Users\Public\SGT-Showdown\server\users.ts:1414:9) at Object.socketReceive (C:\Users\Public\SGT-Showdown\server\users.ts:1686:12) at Object.onSpawn (C:\Users\Public\SGT-Showdown\server\sockets.ts:53:11) at processTicksAndRejections (node:internal/process/task_queues:96:5

I believe that this was fixed in 1c756b1. Here is my working Dockerfile:

FROM ubuntu:latest

RUN apt update
RUN apt-get install git nodejs npm curl vim -y

# Cloning showdown
WORKDIR /root/
RUN git clone https://github.com/smogon/pokemon-showdown.git
WORKDIR /root/pokemon-showdown

# Setting up config
RUN cp -r config/config-example.js config/config.js

# Changing to correct node version
RUN npm install -g n
RUN n 14.18.2

# Setup
RUN npm install

RUN n latest does not work for me, I have to explicitly use RUN n 14.18.2. This might be helpful to include in the server/README.md (#8826)

Did you try this dockerfile? It works perfectly fine for me.

I have not tried that no. I followed the step-by-step from the hub, installed. launched. Worked fine several months ago for about... a month or more? Then I didn't check it for awhile.

That error message I pasted was from today.