microsoft / vscode-remote-release

Visual Studio Code Remote Development: Open any folder in WSL, in a Docker container, or on a remote machine using SSH and take advantage of VS Code's full feature set.
https://aka.ms/vscode-remote
Other
3.62k stars 277 forks source link

net::ERR_CONTENT_LENGTH_MISMATCH error in case run app by devcontainer at Apple M1 #5719

Closed EchEdward closed 2 years ago

EchEdward commented 2 years ago

Steps to Reproduce:

  1. Create dev container from config files (download);
  2. Run app by Debug: Select and Start Debugging > Python: Odoo Server;
  3. Open any browser at page localhost:8069;
  4. Log in by user: admin password: admin;
  5. Open code inspector, disable cache, refresh page until catch net::ERR_CONTENT_LENGTH_MISMATCH error in console tab. This error arise randomly.

I think that this error arises through the fault Remote Containers tool, because I've tried to run the same container by Docker but haven't caught this error.

Download Dockerfile

docker build -t odoo_single .   
docker run --rm -d -p 8069:8069 --name odoo_single-web odoo_single    

Also I've tried to run devcontainer and simple container at Windows 11 and Ubuntu 20 (x86-64/AMD64) but haven't caught this error.

Do you know it is the bug of remote container at Apple M1 or my devcontainer config is not correct?

I very like using remote container, it is so convenient. So I hope you can help me to solve this problem.

Code of devcontainer config and simple container you can read below:

Devcontainer config code *.devconatiner/devcontainer.json* ```jsonc { "name": "KABS Project", "build": { // Dockerfile path "dockerfile": "Dockerfile", // Path for docker build context "context": "..", // Docker build args "args": { "USER_NAME": "devuser", "PASSWORD": "1111", "WORKSPACE_FOLDER": "${localWorkspaceFolderBasename}", "POSTGRES_PORT": "2345", "POSTGRES_VERSION": "13", "POSTGRES_DB": "odoo13db", }, }, // Redefinition mounted folder by default // (Because incorrectly work at mac os) "workspaceMount": "source=${localWorkspaceFolder},target=/workspace,type=bind,consistency=cached", // User for login in devcontainer "remoteUser": "devuser", // Folder where project will be installed "workspaceFolder": "/opt/${localWorkspaceFolderBasename}", // Env vars that will be added when devcontainer is run "remoteEnv": { "PYTHONPATH": "/opt/${localWorkspaceFolderBasename}/odoo", }, // "runArgs": ["--net=host"], // Ports that will be allowed outside of devcontainer by default // It can be edited from run devcontainer "forwardPorts": [8069,2345], // Command that will be run once after fist launching of devcontainer "postCreateCommand": "bash /workspace/.devcontainer/postcreate.sh", // Command that will be run every time when devcontainer is attached "postAttachCommand": "sudo service postgresql start", // List of extensions IDs for VS Code that will be installed for this devcontainer "extensions": [ "ms-python.python", "ms-python.vscode-pylance", ], // Global settings for devcontainer. They will be set once, and for changing them // needs to rebuild devcontainer "settings": { "terminal.integrated.profiles.linux": { "bash": { "path": "/bin/bash" } }, "terminal.integrated.defaultProfile.linux": "bash", "terminal.integrated.shell.linux": "/bin/bash", "terminal.integrated.inheritEnv": true, "python.defaultInterpreterPath": "/usr/local/bin/python", "python.languageServer": "Pylance", }, } ``` *.devconatiner/Dockerfile* ```Dockerfile FROM python:3.7 # Default args ARG USER_UID=9999 ARG USER_GID=$USER_UID # Global project variables ARG USER_NAME ARG PASSWORD ARG WORKSPACE_FOLDER ARG POSTGRES_PORT ARG POSTGRES_DB ARG POSTGRES_VERSION # Setting up global project variables like container environment variables ENV USER_NAME=$USER_NAME ENV PASSWORD=$PASSWORD ENV WORKSPACE_FOLDER=$WORKSPACE_FOLDER ENV POSTGRES_PORT=$POSTGRES_PORT ENV POSTGRES_DB=$POSTGRES_DB # Setup developer user RUN groupadd --gid $USER_GID $USER_NAME \ && useradd --uid $USER_UID --gid $USER_GID -m $USER_NAME -p $(openssl passwd -crypt $PASSWORD) \ && apt-get update \ && apt-get install -y sudo \ && echo $USER_NAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USER_NAME \ && chmod 0440 /etc/sudoers.d/$USER_NAME\ && mkdir /opt/${WORKSPACE_FOLDER}\ && mkdir /home/$USER_NAME/.ssh\ && chown ${USER_NAME}:${USER_NAME} /home/$USER_NAME/.ssh\ && chown ${USER_NAME}:${USER_NAME} /opt/${WORKSPACE_FOLDER}\ && apt-get -y install git # Setup local postgresql db RUN apt-get -y install postgresql-$POSTGRES_VERSION\ && echo "port = $POSTGRES_PORT" >> /etc/postgresql/${POSTGRES_VERSION}/main/postgresql.conf\ && sudo service postgresql start\ && sudo -u postgres createuser --superuser $USER_NAME\ && sudo -u postgres psql -c "alter role $USER_NAME with password '$PASSWORD'" # Setup additional dependencies for container RUN apt-get -y install libxml2-dev libxslt1-dev libldap2-dev\ libsasl2-dev libtiff5-dev libjpeg62-turbo-dev libopenjp2-7-dev\ zlib1g-dev libfreetype6-dev liblcms2-dev libwebp-dev\ libharfbuzz-dev libfribidi-dev libxcb1-dev libpq-dev\ xvfb libfontconfig wkhtmltopdf USER $USER_NAME ``` *.devcontainer/postcreate.sh* ```sh # Set general settings for work folder chmod 400 ~/.ssh sudo chown $(whoami):$(whoami) /opt/${WORKSPACE_FOLDER} sudo cp -avr /workspace/.devcontainer/.vscode/ /opt/${WORKSPACE_FOLDER}/.vscode/ sudo chown -R $(whoami):$(whoami) /opt/${WORKSPACE_FOLDER}/.vscode/ # Add allowed domens to exclude confirmation request for git clone sudo ssh-keyscan -H github.com >> ~/.ssh/known_hosts # Project setup and project dependencies git clone -b 13.0 --single-branch --depth 1 https://github.com/odoo/odoo.git /opt/${WORKSPACE_FOLDER}/odoo sudo pip3 install --upgrade pip sudo pip3 install -r /opt/${WORKSPACE_FOLDER}/odoo/requirements.txt # Setup links, db and config sudo service postgresql start createdb ${POSTGRES_DB} bash /workspace/.devcontainer/odooconfcreate.sh # .vscode dependencies python3 /opt/${WORKSPACE_FOLDER}/odoo/odoo-bin -c /opt/${WORKSPACE_FOLDER}/odoo.conf --stop-after-init -i all ``` *.devcontainer/odooconfcreate.sh* ```sh echo -e "[options]\n"\ "db_host=localhost\n"\ "db_port=$POSTGRES_PORT\n"\ "db_user=$(whoami)\n"\ "db_password=$PASSWORD\n"\ "db_name=$POSTGRES_DB\n"\ "addons_path=/opt/$WORKSPACE_FOLDER/odoo/addons"\ >> /opt/$WORKSPACE_FOLDER/odoo.conf ``` *.devcontainer/.vscode/launch.json* ```jsonc { "version": "0.2.0", "configurations": [ { "name": "Python: Odoo Server", "type": "python", "request": "launch", "noDebug": true, "python": "${command:python.interpreterPath}", "console": "integratedTerminal", "program": "${workspaceRoot}/odoo/odoo-bin", "args": [ "--config=${workspaceRoot}/odoo.conf", ], "cwd": "${workspaceRoot}", }, ] } ```
Dockerfile code ``` Dockerfile FROM python:3.7 # Default args ARG USER_UID=9999 ARG USER_GID=$USER_UID # Global project variables ARG USER_NAME=devuser ARG PASSWORD=1111 ARG WORKSPACE_FOLDER=workspace ARG POSTGRES_PORT=5432 ARG POSTGRES_DB=odoo ARG POSTGRES_VERSION=13 # Setup developer user RUN groupadd --gid $USER_GID $USER_NAME \ && useradd --uid $USER_UID --gid $USER_GID -m $USER_NAME -p $(openssl passwd -crypt $PASSWORD) \ && apt-get update \ && apt-get install -y sudo \ && echo $USER_NAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USER_NAME \ && chmod 0440 /etc/sudoers.d/$USER_NAME\ && mkdir /opt/${WORKSPACE_FOLDER}\ && mkdir /home/$USER_NAME/.ssh\ && chown ${USER_NAME}:${USER_NAME} /home/$USER_NAME/.ssh\ && chown ${USER_NAME}:${USER_NAME} /opt/${WORKSPACE_FOLDER}\ && apt-get -y install git # Setup local postgresql db RUN apt-get -y install postgresql-$POSTGRES_VERSION\ && echo "port = $POSTGRES_PORT" >> /etc/postgresql/${POSTGRES_VERSION}/main/postgresql.conf\ && sudo service postgresql start\ && sudo -u postgres createuser --superuser $USER_NAME\ && sudo -u postgres psql -c "alter role $USER_NAME with password '$PASSWORD'" # Setup additional dependencies for container RUN apt-get -y install libxml2-dev libxslt1-dev libldap2-dev\ libsasl2-dev libtiff5-dev libjpeg62-turbo-dev libopenjp2-7-dev\ zlib1g-dev libfreetype6-dev liblcms2-dev libwebp-dev\ libharfbuzz-dev libfribidi-dev libxcb1-dev libpq-dev\ xvfb libfontconfig wkhtmltopdf USER $USER_NAME WORKDIR /opt/${WORKSPACE_FOLDER}/ RUN git clone -b 13.0 --single-branch --depth 1 https://github.com/odoo/odoo.git /opt/${WORKSPACE_FOLDER}/odoo \ && sudo pip3 install -r /opt/${WORKSPACE_FOLDER}/odoo/requirements.txt RUN sudo service postgresql start\ && createdb ${POSTGRES_DB}\ && echo "[options]\n"\ "db_host=localhost\n"\ "db_port=$POSTGRES_PORT\n"\ "db_user=$(whoami)\n"\ "db_password=$PASSWORD\n"\ "db_name=$POSTGRES_DB\n"\ "addons_path=/opt/$WORKSPACE_FOLDER/odoo/addons"\ >> /opt/$WORKSPACE_FOLDER/odoo.conf\ && python3 odoo/odoo-bin -c odoo.conf --stop-after-init -i all EXPOSE 8069 CMD sudo service postgresql start && python3 odoo/odoo-bin -c odoo.conf ```
Chuxel commented 2 years ago

We have seen issues with bugs in Debian affecting M1 macs. This is the reason we do not pre-build any of our images that use Debian 10/buster or Ubuntu 20.04/focal. Check your resulting image to see if its on one of those versions (run cat /etc/os-release). It should be on Debian 11/bullseye looking at your Dockerfile.

I'm not aware of anything in our extension that would cause this off hand unless @Tyriar or @chrmarti are aware of something specific to the terminal - its more likely a Docker Desktop issue (e.g. w/QEMU that it uses) or the python image.

Tyriar commented 2 years ago

Doubt this is a problem on my end

EchEdward commented 2 years ago

Thanks for answers. I've checked at /etc/os-release and it is the same as for mcr.microsoft.com/vscode/devcontainers/python:3.7-bullseye

PRETTY_NAME="Debian GNU/Linux 11 (bullseye)"
NAME="Debian GNU/Linux"
VERSION_ID="11"
VERSION="11 (bullseye)"
VERSION_CODENAME=bullseye
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"

@Chuxel , maybe you are right about that is Docker Desktop issue, but why if I run it like simple container (not devcontainer) it work great, it look like Docker Desktop works without problem. If I run it like devcontainer I randomly catch net::ERR_CONTENT_LENGTH_MISMATCH. I've also tried to run devcontainer at amd64 by Rosetta 2 emulator and caught same error. Maybe problem is in the tool for forwarding Ports from container to local OS?

If you have problem with some linux distributions, could you give me list of linux distribution that work normal at Apple Silicon (M1), I want to check them with my problem to give you more information.

Chuxel commented 2 years ago

@EchEdward M1 support in the Docker ecosystem is new, so there are issues. Linux arm64 has been around for a while, but macOS is just far enough off of that not to be on the common path since it runs in a VM. macOS for M1 is new, QEMU support for mac M1 is new, and Docker Desktop for macOS M1 is new. Nothing deploys into production this way.

The bug I mention is a libssl OS bug that only affects certain cyphers. So you can use it fine for a while, then hit some code path and you get a seg fault. Distros affected are mentioned in Docker Desktop's in the release notes https://docs.docker.com/desktop/mac/release-notes/3.x/#known-issues However, you'll see various M1 specific issues at https://github.com/docker/for-mac/issues

@alexr00 @chrmarti - Any thoughts on whether this is something with the port forwarding mechanism?

EchEdward commented 2 years ago

@Chuxel thanks for quick feedback. I agree with you that ARM is new for Docker and macOS and for new technology is normal to have some problem. I've checked links that you given me, but found nothing that could be connected with my problem. Also I've tried to use Alpine based images to test my problem and caught same error. Since not me and not your team don't have any ideas about above problem I think that we can close this issue. I hope that future updates of Docker or MacOS or Remote Container extension will fix this problem by chance. Thanks a lot for you work.

alexr00 commented 2 years ago

@EchEdward thank you for your understanding! I'm closing the issue, but if we start getting more reports of the same problem outside of ARM then I'll reopen for investigation.