Skip to content

remoteRoot and sourceMaps do not work properly with TypeScript and Docker while debugging #100973

Description

  • VSCode Version: 1.46.1
  • OS Version: Ubuntu 18.04

Steps to Reproduce:

  1. $ git clone git@github.com:Sir-hennihau/node-mongo-typescript-docker-setup.git
  2. $ git checkout df02470621e5599746477f1614bdb140e14e11aa
  3. $ cd node-mongo-typescript-docker-setup
  4. $ docker-compose up
  5. Attach debugger (config is included)
  6. Check "Loaded Scripts" section

Does this issue occur when all extensions are disabled?: Yes
Screenshot from 2020-06-24 20-51-30

I'm trying to develop with this stack: NodeJS, Docker ( + Docker-Compose), TypeScript and VSCode. But the debugger will not work properly.

There seems still to be a problem with using the remoteRoot configuration within launch.json (I need it in another project, the linked one is just an example repo) and TypeScript source maps. As you can see in the screenshot, the loaded script in the debugger looks way different from the original one. This gets even messier in bigger files.

According to this statement, there should have been a fix to this behaviour in 2016 already, if I'm correct? So I'm curious what my issue could be here or if it just wasn't fixed yet?

// launch.json
{
  "version": "0.2.0",
  "configurations": [
    {
      "type": "node",
      "request": "attach",
      "name": "attach",
      "port": 9229,
      "localRoot": "${workspaceFolder}",
      "remoteRoot": "/app"
    }
  ]
}
// I also tried setting "sourceMaps": true, but it didn't change anything
# Dockerfile
FROM node:14-alpine

WORKDIR /app

COPY package*.json ./

RUN npm i

COPY . .

EXPOSE 3000
EXPOSE 9229

CMD ["npm", "run", "dev"]
# docker-compose.yml
version: "3"

services:
  node-app:
    build: .
    volumes:
      - .:/app
      - /app/node_modules
    ports:
      - 3000:3000
      - 9229:9229
// index.ts
import express from "express";

const app = express();

const PORT = 3000;

app.get("/", (req, res) => {
  res.send("hello world <333.");
});

app.listen(PORT, () => {
  console.log(`App listening on ${PORT}`);
});
// tsconfig.json
{
  "compilerOptions": {
    "esModuleInterop": true,
    "forceConsistentCasingInFileNames": true,
    "inlineSourceMap": true, // <--- Also tried using the "sourceMap: true" property instead or without any sourcemap config, but no success here
    "module": "commonjs",
    "outDir": "build",
    "skipLibCheck": true,
    "strict": true,
    "target": "ESNext"
  }
}
// package.json
  "scripts": {
    "dev": "nodemon --exec 'node --inspect=0.0.0.0:9229 --require ts-node/register source/index.ts'"
  }

fyi: when you don't pass a remoteRoot value, the problem does not occur (but certain folder structures will not be debuggable then).

Activity

  1. changed the title [-]remoteRoot and sourceMaps[/-] [+]remoteRoot and sourceMaps do not properly work with TypeScript and Docker while debugging[/+] on Jun 24, 2020
  2. changed the title [-]remoteRoot and sourceMaps do not properly work with TypeScript and Docker while debugging[/-] [+]remoteRoot and sourceMaps do not work properly with TypeScript and Docker while debugging[/+] on Jun 24, 2020
  3. weinand commented on Jun 24, 2020

    @weinand
    Contributor

    I recommend to use the VS Code "Remote Development" and "Remote Container" extensions.
    With this approach there is no need to deal with localRoots and remoteRoots.

    Please see https://code.visualstudio.com/docs/remote/remote-overview

  4. Sir-hennihau commented on Jun 25, 2020

    @Sir-hennihau
    Author

    Thanks, I didn't know about that possibility within VSCode. For now, it works!

  5. locked and limited conversation to collaborators on Aug 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

debugDebug viewlet, configurations, breakpoints, adapter issues

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions