microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
164.43k stars 29.34k forks source link

unable to debug express project #9624

Closed ta3pks closed 7 years ago

ta3pks commented 8 years ago

Steps to Reproduce:

  1. create a debug point
  2. if the debug point is global get following error
node: ../../nan/nan_object_wrap.h:33: static T* Nan::ObjectWrap::Unwrap(v8::Local<v8::Object>) [with T = Canvas]: Assertion `object->InternalFieldCount() > 0' failed.
kieferrm commented 8 years ago

@NikosEfthias Pls provide concrete steps with concrete source and node and npm version numbers how to reproduce the problem so that we don't have to guess. Thanks a ton!

ta3pks commented 8 years ago

npm 3.9.5 node 6.2.2 the debug point is created as you see in the photo and debugger fails again as you can see in the photo

ta3pks commented 8 years ago

when i run app with node itself theres no problem the app runs but the vscode debugger reports error

kieferrm commented 8 years ago

@NikosEfthias can you provide a bit more information about what your workspace contains. npm package dependencies etc. Thanks.

weinand commented 8 years ago

@NikosEfthias the error is not reported by VS Code but by node itself. Could you please try the same with node-inspector. Thanks.

weinand commented 8 years ago

@NikosEfthias I assume with 'debug point' you mean a 'break point', correct? But what do you mean with 'global debug point'?

ta3pks commented 8 years ago

İ meant a break point that is on the goal scope in my program not in the scope of any function if I create a break point in a function I don't get this error @weinand

weinand commented 8 years ago

@NikosEfthias are you getting the node error when setting the breakpoint or when hitting the breakpoint?

ta3pks commented 8 years ago

@weinand there is no node error if i run app with nodejs it works without any issue . and when i put a break point inside a fonction it still works perfect but if i put break point to somewhere in the global scope when it hits the point debugger crashes

weinand commented 8 years ago

@NikosEfthias the error message does not originate from VS Code but comes from some native code used in the 'nan' npm module. The 'nan' module is not used in the VS Code debugger, so it must be a direct or indirect dependency of your express program.

If your express program 'runs in node without problems' does not mean much if you do not run node in debug mode. So you will have to pass the '--debug' or '--debug-brk' flag to node if you want to prove that your programs 'runs without any issues'. In addition you will have to attach a different debugger than VS Code to node and hit a breakpoint successfully in order to prove that VS Code is the culprit.

That's the reason why I've suggested that you try to reproduce the problem with the 'node-inspector' debugger. If that works then we can be sure that VS Code is the culprit.

Alternatively you can do the following to help us understand the problem:

ta3pks commented 8 years ago

i cannot reproduce the same issue with node inspector it just works fine

weinand commented 8 years ago

@NikosEfthias thanks, so this is a VS Code bug. But without reproducible steps I cannot investigate.

ta3pks commented 8 years ago

i cannot share the project i am writing but i am using canvas module it can be because of this though i am not sure canvas is a native c++ module

ta3pks commented 8 years ago

seems on new vscode version no solution to this bug yet

weinand commented 8 years ago

@NikosEfthias without a reproducible case I cannot investigate.

ta3pks commented 8 years ago

is there any way to investigate without sharing the entire code ? could you check remotely ?

ta3pks commented 8 years ago

I faced the same problem again, and again I am using the node-canvas module . Here is my snippet that you can reproduce the issue with:

const barc = new (require("barcode-generator"))
const fs = require("fs");
var Canvas = require('canvas')
    , Image = Canvas.Image
    , canvas = new Canvas(340.818, 226.77, 'pdf')
    , ctx = canvas.getContext('2d');
// const printer = require("printer");
let coupon = {
//someData
}
var cell = 35.008;
var margin = 11.171;
var fontSize = 22;
var draw = function () {
    data = "123456test"
    ctx.beginPath();
    ctx.textBaseline = "hanging";
    ctx.font = "18px monospace";

    ctx.strokeStyle = "#3C3C3C ";

    var img = new Image;
    var barcode = barc.code128(data, 200, 35);
    img.src = barcode;

    ctx.drawImage(img, 18.488, 172.448);

    coupon.card.numbers.map(function (r, row) {
        coupon.card.numbers[row].map(function (c, num) {
            ctx.strokeRect(margin + cell * num, margin + row * cell, cell, cell);

            if (c.number) {
                var left = c.number > 9 ? 7 : 12;
                ctx.fillText(c.number, margin + cell * num + left, margin + row * cell + 12);
            } else {
                ctx.fillRect(margin + cell * num, margin + row * cell, cell, cell);
            }

        });

    });
    const now = new Date(coupon.created_at)
    function padDate(dateObj) {
        const {getFullYear: yr, getMonth: mn, getDay: day} = now
        let date = yr.call(now) + "-"
        date += mn.call(now) < 10 ? mn.call(now).toString().split().unshift("0").join("") : mn.call(now)
        date += "-"
        date += day.call(now) < 10 ? day.call(now).toString().split().unshift("0").join("") : day.call(now)
        return date
    }
    ctx.font = "12px monospace";
    ctx.fillText("Kupon No:", margin, 138.8865);
    ctx.fillText("Fiyat   :", margin, 156.0101);
    ctx.fillText("Oyun No:", 200.6822, 138.8865);
    ctx.fillText("Tarih  :", 200.6822, 156.0101);
    ctx.fillText(coupon.cardId, 88.5042, 138.8865);
    ctx.fillText(coupon.cardPrice + ' TL', 88.5042, 156.0101);
    ctx.fillText(coupon.gameIndex, (238.3564 + 25.0), 138.8865);
    ctx.fillText(/*coupon.created_at*/padDate(), (238.3564 + 25.0), 156.0101);
}
draw();
pinxue commented 7 years ago

I run into same issue with node-opencv.

Env: VSCode 1.11.2, node 7.6.0 (same issue with older ones like 6.x), npm 4.1.2

Reproduce info:

in package.json: "dependencies": { "opencv": "^6.0.0" }

hello.js: const cv = require('opencv'); //set a breakpoint here and step over to reproduce // or set a breakpoint at any line after require()

Additional Info:

  1. The same program runs fine from command line, even from VSCode built-in terminal.
  2. In VSCode, run without breakpoint works fine.
  3. VSCode attach to "node --debug-brk=5858 --nolazy hello.js" has same issue.
  4. To launch by node-debug then step in chrome works.
pinxue commented 7 years ago

Well, seems we may narrow down to legacy debug protocol support. When I use "node --inspect --debug-brk face.js" (requires Node.js 6.3+), VSCode debug works.

FYI: so far I add "protocol": "inspector" attribute to launch.json as a workaround.

weinand commented 7 years ago

@NikosEfthias I am not able to reproduce your problem with your code snippet from Oct 10, 2016 and VS Code 1.11.2 and node.js 6.5 and 7.4.

Setting breakpoints and hitting them works fine both in Ubuntu 16.04 and macOS 10.12.4. Debugging with node-debug defaults to the "legacy" protocol because both node.js version are < 8.0.

I've installed the "barcode-generator" and then the dependency "cairo" by following the steps on https://www.npmjs.com/package/canvas. "npm install" seems to build some native code, so make sure that you run "npm install" again after installing a new version of node.js.

vscodebot[bot] commented 7 years ago

This issue has been closed automatically because it needs more information and has not had recent activity. Please refer to our guidelines for filing issues. Thank you for your contributions.