mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
87ebeec54b6ac16da5584df2bd96ba400cb5dc9b
The `meteor debug` command behaves like Node's `--inspect-brk` flag, in
that it attempts to pause the server before executing any server code.
However, simply passing the `--inspect-brk` flag to Node causes execution
to pause on the very first line of code, which is not good for setting any
breakpoints, because no server code has actually loaded yet.
Instead, the `meteor debug` command uses Node's `--inspect` flag to enable
debugging without an initial pause, then manually pauses at an appropriate
moment during server startup. Ideally, the pause should last until an
inspector client has been attached to the process, at which point the
developer has a chance to set any desired breakpoints, then clicks the
continue button to proceed with server startup.
The most difficult part of this process is detecting when the inspector
client has attached. Previously, the parent process listened for the child
process to print a "Debugger attached" message to STDERR, which happens as
a result of this `fprintf` call in Native C++:
7cff6e80bf/src/inspector_io.cc (L396)
However, this message was not printed in some cases, especially on Windows
(#9165), and required inter-process communication even in the ideal case.
All of that logic is gone now, thanks to this commit.
This commit takes advantage of a difference in behavior of the `debugger`
keyword depending on whether or not an inspector client is attached. When
no client is attached, the `debugger` keyword is a no-op that takes no
time (or very little time) to execute. Once a client has attached, the
`debugger` keyword triggers a breakpoint that lasts until the developer
explicitly continues execution through the client UI. Needless to say,
this makes the `debugger` keyword take longer than a no-op.
Because the `debugger` keyword does nothing until a client connects, we
can safely poll a `pause` function containing a `debugger` keyword at a
frequent interval (say, every 500ms). Once a client connects, the
`debugger` keyword will become active, pausing the server at exactly the
point we hoped. The difference is easy to detect by timing the `pause()`
function call. Once the `debugger` keyword becomes active, we stop polling
and allow server startup to continue.
Elegant!
Fixes #9165.
Meteor is an ultra-simple environment for building modern web applications.
With Meteor you write apps:
- in modern JavaScript
- that send data over the wire, rather than HTML
- using your choice of popular open-source libraries
Try a getting started tutorial:
Next, read the guide and the documentation.
Quick Start
On Windows, the installer can be found at https://www.meteor.com/install.
On Linux/macOS, use this line:
curl https://install.meteor.com/ | sh
Create a project:
meteor create try-meteor
Run it:
cd try-meteor
meteor
Developer Resources
Building an application with Meteor?
- Announcement list: sign up at http://www.meteor.com/
- Having problems? Ask for help at: http://stackoverflow.com/questions/tagged/meteor
- Discussion forums: https://forums.meteor.com/
Interested in helping or contributing to Meteor? These resources will help:
We are hiring! Visit meteor.io/jobs to learn more about working full-time on the Meteor project.
Uninstalling Meteor
Aside from a short launcher shell script, Meteor installs itself inside your home directory. To uninstall Meteor, run:
rm -rf ~/.meteor/
sudo rm /usr/local/bin/meteor
On Windows, just run the uninstaller from your Control Panel.
Languages
JavaScript
91.1%
TypeScript
3.9%
Shell
0.9%
Java
0.7%
Swift
0.7%
Other
2.5%
