Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doesn't work in VSC 1.11.1 on Mac #16

Open
jamesliu668 opened this issue Apr 26, 2017 · 8 comments
Open

Doesn't work in VSC 1.11.1 on Mac #16

jamesliu668 opened this issue Apr 26, 2017 · 8 comments

Comments

@jamesliu668
Copy link

Hello,

I am working in VSC version 1.11.1 and install the "Debug for PhantomJS 0.1.1". When I click the debug button, I get following error message:

******** Error in DebugAdapter - Unhandled promise rejection: {"code":-32000,"message":"Execution context with given id not found."}

Here is my debug launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch",
"type": "phantomjs",
"request": "launch",
"file": "${workspaceRoot}/test.js",
"webRoot": "${workspaceRoot}",
"runtimeExecutable": "/usr/local/etc/phantomjs/bin/phantomjs",
"runtimeArgs": [],
"scriptArgs": [],
"sourceMaps": true
}
]
}

@iradul
Copy link
Owner

iradul commented May 2, 2017

Add those to you launch.json:

  "verboseDiagnosticLogging": true,
  "diagnosticLogging": true

Then run it again and copy the output here.

@jamesliu668
Copy link
Author

Thanks for the reply. Here is my debug log (a very long txt):

Verbose logs are written to /Users/james/.vscode/extensions/vscode-phantomjs-debug.txt
3:27:12 PM, 5/31/2017
OS: darwin x64
Adapter node: v7.4.0 x64
vscode-chrome-debug-core: 3.1.0
›From client: initialize({"clientID":"vscode","adapterID":"phantomjs","pathFormat":"path","linesStartAt1":true,"columnsStartAt1":true,"supportsVariableType":true,"supportsVariablePaging":true,"supportsRunInTerminalRequest":true})
›To client: {"seq":0,"type":"response","request_seq":1,"command":"initialize","success":true,"body":{"exceptionBreakpointFilters":[{"label":"All Exceptions","filter":"all","default":false},{"label":"Uncaught Exceptions","filter":"uncaught","default":true}],"supportsConfigurationDoneRequest":true,"supportsSetVariable":true,"supportsConditionalBreakpoints":true,"supportsCompletionsRequest":true}}
›From client: launch({"name":"Launch","type":"phantomjs","request":"launch","file":"/Users/james/phantom/test.js","webRoot":"/Users/james/phantom","runtimeExecutable":"/usr/local/etc/phantomjs/bin/phantomjs","runtimeArgs":[],"scriptArgs":[],"sourceMaps":true,"verboseDiagnosticLogging":true,"diagnosticLogging":true})
spawn('/usr/local/etc/phantomjs/bin/phantomjs', ["--remote-debugger-port=9222","/Users/james/phantom/test.js"])
›To target: "{"id":1,"method":"Debugger.enable"}"
›To target: "{"id":2,"method":"Runtime.enable"}"
›To target: "{"id":3,"method":"Runtime.runIfWaitingForDebugger"}"
›To target: "{"id":4,"method":"Runtime.run"}"
›To target: "{"id":5,"method":"Console.enable"}"
›From target: {"result":{},"id":1}
›From target: {"method":"Runtime.executionContextCreated","params":{"context":{"id":4,"isPageContext":true,"name":"","frameId":"0.1"}}}
›From target: {"method":"Runtime.executionContextCreated","params":{"context":{"id":4,"isPageContext":false,"name":"file://","frameId":"0.1"}}}
›From target: {"result":{},"id":2}
›From target: {"method":"Debugger.scriptParsed","params":{"scriptId":"1","url":"phantomjs://platform/webpage.js","startLine":0,"startColumn":0,"endLine":895,"endColumn":148}}
Paths.scriptParsed: could not resolve phantomjs://platform/webpage.js to a file under webRoot: /Users/james/phantom. It may be external or served directly from the server's memory (and that's OK).
›From target: {"method":"Debugger.scriptParsed","params":{"scriptId":"2","url":"phantomjs://platform/fs.js","startLine":0,"startColumn":0,"endLine":270,"endColumn":133}}
Paths.scriptParsed: could not resolve phantomjs://platform/fs.js to a file under webRoot: /Users/james/phantom. It may be external or served directly from the server's memory (and that's OK).
›From target: {"method":"Debugger.scriptParsed","params":{"scriptId":"3","url":"phantomjs://platform/system.js","startLine":0,"startColumn":0,"endLine":32,"endColumn":145}}
Paths.scriptParsed: could not resolve phantomjs://platform/system.js to a file under webRoot: /Users/james/phantom. It may be external or served directly from the server's memory (and that's OK).
›From target: {"method":"Debugger.scriptParsed","params":{"scriptId":"4","url":"phantomjs://platform/bootstrap.js","startLine":0,"startColumn":0,"endLine":327,"endColumn":0}}
Paths.scriptParsed: could not resolve phantomjs://platform/bootstrap.js to a file under webRoot: /Users/james/phantom. It may be external or served directly from the server's memory (and that's OK).
›From target: {"method":"Debugger.scriptParsed","params":{"scriptId":"5","url":"","startLine":0,"startColumn":0,"endLine":0,"endColumn":122}}
›From target: {"method":"Debugger.scriptParsed","params":{"scriptId":"6","url":"phantomjs://code/test.js","startLine":0,"startColumn":0,"endLine":23,"endColumn":1}}
Paths.scriptParsed: resolved phantomjs://code/test.js to /Users/james/phantom/test.js. webRoot: /Users/james/phantom
›From target: {"error":{"code":-32601,"message":"'Runtime.runIfWaitingForDebugger' wasn't found"},"id":3}
›From target: {"result":{},"id":4}
›From target: {"method":"Debugger.scriptParsed","params":{"scriptId":"11","url":"","startLine":0,"startColumn":0,"endLine":1412,"endColumn":0}}
›From target: {"method":"Console.messageAdded","params":{"message":{"source":"console-api","level":"log","text":"Status: success","type":"log","line":11,"column":16,"url":"phantomjs://code/test.js","repeatCount":1,"parameters":[{"type":"string","value":"Status: success"}],"stackTrace":[{"functionName":"","url":"phantomjs://code/test.js","lineNumber":11,"columnNumber":16},{"functionName":"_onPageOpenFinished","url":"phantomjs://platform/webpage.js","lineNumber":286,"columnNumber":27}]}}}
Status: success
›From target: {"method":"Console.messageAdded","params":{"message":{"source":"console-api","level":"log","text":"[object Object]","type":"log","line":19,"column":20,"url":"phantomjs://code/test.js","repeatCount":1,"parameters":[{"type":"object","objectId":"{"injectedScriptId":4,"id":1}","className":"Object","description":"Object"}],"stackTrace":[{"functionName":"","url":"phantomjs://code/test.js","lineNumber":19,"columnNumber":20},{"functionName":"_onPageOpenFinished","url":"phantomjs://platform/webpage.js","lineNumber":286,"columnNumber":27}]}}}
Object
›From target: {"result":{},"id":5}
›To client: {"seq":0,"type":"event","event":"initialized"}
›To client: {"seq":0,"type":"response","request_seq":2,"command":"launch","success":true}
›From client: setBreakpoints({"source":{"path":"/Users/james/phantom/test.js","name":"test.js"},"lines":[2],"breakpoints":[{"line":2}],"sourceModified":false})
SourceMaps.setBP: SourceMaps are enabled but /Users/james/phantom/test.js is a runtime script
Paths.setBP: Resolved /Users/james/phantom/test.js to phantomjs://code/test.js
›To target: "{"id":6,"method":"Debugger.setBreakpointByUrl","params":{"urlRegex":"phantomjs:\\/\\/code\\/test\\.js","lineNumber":2,"columnNumber":0}}"
›From target: {"result":{"breakpointId":"/phantomjs:\/\/code\/test\.js/:2:0","locations":[{"scriptId":"6","lineNumber":2,"columnNumber":0}]},"id":6}
›To client: {"seq":0,"type":"response","request_seq":3,"command":"setBreakpoints","success":true,"body":{"breakpoints":[{"id":1000,"verified":true,"line":2,"column":1}]}}
›From client: setExceptionBreakpoints({"filters":["uncaught"]})
›To target: "{"id":7,"method":"Debugger.setPauseOnExceptions","params":{"state":"uncaught"}}"
›From target: {"result":{},"id":7}
›To client: {"seq":0,"type":"response","request_seq":4,"command":"setExceptionBreakpoints","success":true}
›From client: configurationDone(undefined)
›To client: {"seq":0,"type":"response","request_seq":5,"command":"configurationDone","success":true}
›From client: threads(undefined)
›To client: {"seq":0,"type":"response","request_seq":6,"command":"threads","success":true,"body":{"threads":[{"id":1,"name":"Thread 1"}]}}
›To target: "{"id":8,"method":"Runtime.evaluate","params":{"expression":"__run()","silent":true,"contextId":1}}"
›From target: {"error":{"code":-32000,"message":"Execution context with given id not found."},"id":8}
******** Error in DebugAdapter - Unhandled promise rejection: {"code":-32000,"message":"Execution context with given id not found."}

I installed my phantomjs with following command line (install it globally):
brew install phantomjs

And above command line will install it in my folder:
/usr/local/etc/phantomjs/bin/phantomjs

and create a soft link in this folder:
/usr/local/bin/phantomjs

Hope this information will be helpful.

@surfline-jherndon
Copy link

If phantom.exit() is not called, SIGINT is not killing the phantomjs process. Replace SIGINT with SIGKILL (I'm not sure if this is desired) in PhantomjsDebugAdapter.js and it works.

@iradul
Copy link
Owner

iradul commented Jun 5, 2017

@jamesliu668 which version of PhantomJS are you using ?

@williamzhao87
Copy link

williamzhao87 commented Jul 25, 2017

I have the same issue on MacOSX 10.11.5, VSCode 1.14, Debugger for PhantomJS 0.1.1, PhantomJS 2.1.1 (installed by brew install phantomjs):

Here is my launch.json:
{
"version": "0.2.0",
"configurations": [
{
"name": "PhantomJS",
"type": "phantomjs",
"request": "launch",
"file": "${workspaceRoot}/test2.js",
"webRoot": "${workspaceRoot}",
"runtimeExecutable": "/usr/local/bin/phantomjs",
"runtimeArgs": [],
"scriptArgs": [],
"sourceMaps": true,
"verboseDiagnosticLogging": true,
"diagnosticLogging": true
}
]
}

test2.js:
var page = require('webpage').create();
page.open("https://localhost:9443/ng", function(ok) { console.log(ok); phantom.exit(); });

Here is my detailed log:
Verbose logs are written to /Users/williamzhao/.vscode/extensions/vscode-phantomjs-debug.txt 12:25:32 PM, 7/25/2017 OS: darwin x64 Adapter node: v7.4.0 x64 vscode-chrome-debug-core: 3.1.0 ›From client: initialize({"clientID":"vscode","adapterID":"phantomjs","pathFormat":"path","linesStartAt1":true,"columnsStartAt1":true,"supportsVariableType":true,"supportsVariablePaging":true,"supportsRunInTerminalRequest":true}) ›To client: {"seq":0,"type":"response","request_seq":1,"command":"initialize","success":true,"body":{"exceptionBreakpointFilters":[{"label":"All Exceptions","filter":"all","default":false},{"label":"Uncaught Exceptions","filter":"uncaught","default":true}],"supportsConfigurationDoneRequest":true,"supportsSetVariable":true,"supportsConditionalBreakpoints":true,"supportsCompletionsRequest":true}} ›From client: launch({"name":"PhantomJS","type":"phantomjs","request":"launch","file":"/Users/williamzhao/workspace/src/main/ui/test2.js","webRoot":"/Users/williamzhao/workspace/src/main/ui","runtimeExecutable":"/usr/local/bin/phantomjs","runtimeArgs":[],"scriptArgs":[],"sourceMaps":true,"verboseDiagnosticLogging":true,"diagnosticLogging":true}) spawn('/usr/local/bin/phantomjs', ["--remote-debugger-port=9222","/Users/williamzhao/workspace/src/main/ui/test2.js"]) ›To target: "{\"id\":1,\"method\":\"Debugger.enable\"}" ›To target: "{\"id\":2,\"method\":\"Runtime.enable\"}" ›To target: "{\"id\":3,\"method\":\"Runtime.runIfWaitingForDebugger\"}" ›To target: "{\"id\":4,\"method\":\"Runtime.run\"}" ›To target: "{\"id\":5,\"method\":\"Console.enable\"}" ›From target: {"result":{},"id":1} ›From target: {"method":"Debugger.scriptParsed","params":{"scriptId":"1","url":"phantomjs://platform/system.js","startLine":0,"startColumn":0,"endLine":32,"endColumn":145}} Paths.scriptParsed: resolved phantomjs://platform/system.js to /Users/williamzhao/workspace/src/main/ui/node_modules/core-js/es7/system.js. webRoot: /Users/williamzhao/workspace/src/main/ui ›From target: {"method":"Debugger.scriptParsed","params":{"scriptId":"2","url":"phantomjs://code/test2.js","startLine":0,"startColumn":0,"endLine":3,"endColumn":1}} Paths.scriptParsed: resolved phantomjs://code/test2.js to /Users/williamzhao/workspace/src/main/ui/test2.js. webRoot: /Users/williamzhao/workspace/src/main/ui ›From target: {"method":"Debugger.scriptParsed","params":{"scriptId":"3","url":"","startLine":0,"startColumn":0,"endLine":0,"endColumn":122}} ›From target: {"method":"Debugger.scriptParsed","params":{"scriptId":"7","url":"","startLine":0,"startColumn":0,"endLine":1412,"endColumn":0}} ›From target: {"method":"Debugger.scriptParsed","params":{"scriptId":"4","url":"phantomjs://platform/fs.js","startLine":0,"startColumn":0,"endLine":270,"endColumn":133}} Paths.scriptParsed: resolved phantomjs://platform/fs.js to /Users/williamzhao/workspace/src/main/ui/node_modules/graceful-fs/fs.js. webRoot: /Users/williamzhao/workspace/src/main/ui ›From target: {"method":"Debugger.scriptParsed","params":{"scriptId":"5","url":"phantomjs://platform/webpage.js","startLine":0,"startColumn":0,"endLine":895,"endColumn":148}} Paths.scriptParsed: could not resolve phantomjs://platform/webpage.js to a file under webRoot: /Users/williamzhao/workspace/src/main/ui. It may be external or served directly from the server's memory (and that's OK). ›From target: {"method":"Debugger.scriptParsed","params":{"scriptId":"6","url":"phantomjs://platform/bootstrap.js","startLine":0,"startColumn":0,"endLine":327,"endColumn":0}} Paths.scriptParsed: could not resolve phantomjs://platform/bootstrap.js to a file under webRoot: /Users/williamzhao/workspace/src/main/ui. It may be external or served directly from the server's memory (and that's OK). ›From target: {"method":"Runtime.executionContextCreated","params":{"context":{"id":8,"isPageContext":true,"name":"","frameId":"0.1"}}} ›From target: {"method":"Runtime.executionContextCreated","params":{"context":{"id":8,"isPageContext":false,"name":"file://","frameId":"0.1"}}} ›From target: {"result":{},"id":2} ›From target: {"error":{"code":-32601,"message":"'Runtime.runIfWaitingForDebugger' wasn't found"},"id":3} ›From target: {"result":{},"id":4} ›From target: {"result":{},"id":5} ›To client: {"seq":0,"type":"event","event":"initialized"} ›To client: {"seq":0,"type":"response","request_seq":2,"command":"launch","success":true} ›From client: setExceptionBreakpoints({"filters":["uncaught"]}) ›To target: "{\"id\":6,\"method\":\"Debugger.setPauseOnExceptions\",\"params\":{\"state\":\"uncaught\"}}" ›From target: {"result":{},"id":6} ›To client: {"seq":0,"type":"response","request_seq":3,"command":"setExceptionBreakpoints","success":true} ›From client: configurationDone(undefined) ›To client: {"seq":0,"type":"response","request_seq":4,"command":"configurationDone","success":true} ›From client: threads(undefined) ›To client: {"seq":0,"type":"response","request_seq":5,"command":"threads","success":true,"body":{"threads":[{"id":1,"name":"Thread 1"}]}} ›To target: "{\"id\":7,\"method\":\"Runtime.evaluate\",\"params\":{\"expression\":\"__run()\",\"silent\":true,\"contextId\":1}}" ›From target: {"error":{"code":-32000,"message":"Execution context with given id not found."},"id":7} ******** Error in DebugAdapter - Unhandled promise rejection: {"code":-32000,"message":"Execution context with given id not found."}

Anyone have any idea why it's failing? Thanks

@bradtgmurray
Copy link

Seeing this as well.

VSCode: Version 1.18.1 (1.18.1)

$ phantomjs --version
2.1.1
  ›To target: "{\"id\":6,\"method\":\"Debugger.setBreakpointByUrl\",\"params\":{\"urlRegex\":\"phantomjs:\\\\/\\\\/code\\\\/index\\\\.js\",\"lineNumber\":3,\"columnNumber\":0}}"
  ›From target: {"result":{"breakpointId":"/phantomjs:\\/\\/code\\/index\\.js/:3:0","locations":[{"scriptId":"4","lineNumber":3,"columnNumber":0}]},"id":6}
  ›To client: {"seq":0,"type":"response","request_seq":3,"command":"setBreakpoints","success":true,"body":{"breakpoints":[{"id":1000,"verified":true,"line":3,"column":1}]}}
  ›From client: setExceptionBreakpoints({"filters":["uncaught"]})
  ›To target: "{\"id\":7,\"method\":\"Debugger.setPauseOnExceptions\",\"params\":{\"state\":\"uncaught\"}}"
  ›From target: {"result":{},"id":7}
  ›To client: {"seq":0,"type":"response","request_seq":4,"command":"setExceptionBreakpoints","success":true}
  ›From client: configurationDone(undefined)
  ›From client: threads(undefined)
  ›To client: {"seq":0,"type":"response","request_seq":5,"command":"configurationDone","success":true}
  ›To client: {"seq":0,"type":"response","request_seq":6,"command":"threads","success":true,"body":{"threads":[{"id":1,"name":"Thread 1"}]}}
  ›To target: "{\"id\":8,\"method\":\"Runtime.evaluate\",\"params\":{\"expression\":\"__run()\",\"silent\":true,\"contextId\":1}}"
  ›From target: {"error":{"code":-32000,"message":"Execution context with given id not found."},"id":8}
******** Error in DebugAdapter - Unhandled promise rejection: {"code":-32000,"message":"Execution context with given id not found."}

@bradtgmurray
Copy link

This seems to happen because the phantomjs process isn't closing correctly, and trying to open a second process gets this error. If I force kill any open phantomjs processes the run option works, but stopping and running again will bring the error back until the kill the orphaned process again.

@franciscohanna92
Copy link

Every time this happens I have to do ps -aux | grep phantomjs to find each process related to the debugging session a kill them manuall with kill <pid>. It seems that phatomjs is ignoring the SIGINT instruction.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants