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

Documentation on how to debug a typescript app such as forum #2427

Closed
beejones opened this issue Apr 8, 2021 · 5 comments
Closed

Documentation on how to debug a typescript app such as forum #2427

beejones opened this issue Apr 8, 2021 · 5 comments

Comments

@beejones
Copy link
Contributor

beejones commented Apr 8, 2021

Is your feature request related to a problem? Please describe.
It is a documentation problem. I am trying to debug the forum app in visual studio code. The only reference on debugging is here: https://microsoft.github.io/CCF/ccf-0.17.2/build_apps/run_app.html#
I am not sure whether the debugging sections applies to the node js environment and if it is, how can I set the debug flag?

Describe the solution you'd like
The forum app description should have a section explaining how to debug the app.

Describe alternatives you've considered
I tried attaching the debugger to all node js processes in order to hit the breakpoint but this did not work.

@letmaik
Copy link
Member

letmaik commented Apr 8, 2021

Duplicate of #1801.

Attaching a JS debugger to debug JS apps running in CCF is not possible currently. Having said that, the ccf-app npm package provides polyfills for most of the native API exposed to CCF JS apps allowing to write unit tests that run in Node.js and can be debugged with a regular JS debugger.

All the JS samples in the repo contain end-to-end tests which query the deployed service. They are lacking unit tests since the polyfills and the ccf-app are a recent addition. The ccf-app package itself though has unit tests that make use of its own polyfill, e.g. for testing the kv module: https://github.com/microsoft/CCF/blob/main/js/ccf-app/test/kv.test.ts. This is how unit tests for apps could be written.

An alternative is to use console.log() but this requires building a debug variant of ccf with verbose logging enabled (-DVERBOSE_LOGGING=ON) since those kinds of log messages are not printed in release variants. There is a tentative plan to publish those debug variants along with the release variants but we haven't got around to it yet. EDIT: console.log and unhandled exceptions are actually dumped to the log, I mixed that up.

@beejones
Copy link
Contributor Author

beejones commented Apr 8, 2021

@letmaik Thank you for the quick response.
This request is not really a repeat because I still believe debugging JS/Typescript should be in the documentation.
So we should develop apps running in the enclave with the ccf app polyfill. This makes them ordinary node apps and as such they can be debugged.
The production app, using ccf-app should be fully tested by means of end to end tests.

@letmaik
Copy link
Member

letmaik commented Apr 8, 2021

This request is not really a repeat because I still believe debugging JS/Typescript should be in the documentation.

OK, agreed.

So we should develop apps running in the enclave with the ccf app polyfill. This makes them ordinary node apps and as such they can be debugged.
The production app, using ccf-app should be fully tested by means of end to end tests.

Yes, that's what I would recommend and I know of at least one internal team doing exactly that.

@letmaik
Copy link
Member

letmaik commented Apr 13, 2021

@beejones I refactored the forum sample in #2455. This now has unit tests that run in node.js and can be debugged. I extended the README a bit for that. I haven't extended the main docs regarding debugging since this depends a lot on how a specific app is written, but hopefully this is a start.

@achamayou
Copy link
Member

The forum example has since been removed, but the polyfill is still there and continues to be the recommended way to debug JS apps.

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

No branches or pull requests

3 participants