Commit Graph

108 Commits

Author SHA1 Message Date
matheusccastro
343fa7f55a Add Assets async API and create findOneAsync on Mongo Connection API too 2023-04-19 19:44:13 -03:00
Edimar Cardoso
3248602f94 Renaming method isFibersEnabled to _isFibersEnabled because it is an internal method. 2022-07-28 15:40:53 -03:00
Edimar Cardoso
bb37fae4c5 Create method to check if Fibers is enabled by flag DISABLE_FIBERS. 2022-07-21 17:20:45 -03:00
filipenevola
1b87f063fc Change reify to @meteorjs/reify 2021-11-24 09:37:24 -03:00
Filipe Névola
cb00f74cd2 Merge branch 'release-2.3' into release-node-14 2021-05-19 17:34:55 -04:00
zodern
07871e9a2e Merge branch 'devel' into reify-runtime-compiler-cache 2021-04-30 17:26:39 -05:00
Jan Dvorak
f154deee3d Merge branch 'devel' into release-node-14 2021-04-29 20:22:01 +02:00
zodern
ad2232e1d3 Skip unnecessarily reading empty cache directory 2021-04-26 14:19:57 -05:00
zodern
6038bd5c59 Add cache for reify runtime compiler 2021-04-26 13:57:12 -05:00
filipenevola
1607d195c7 merge devel to node-14 branch 2021-03-15 19:04:10 -04:00
PrestonGiorgianni
f0aef7afb0 Reorder code to fix absoluteFilePath on windows fixes #11312 2021-03-15 13:46:14 -07:00
Bruce Johnson
85da5b4186 use includes instead of indexOf 2021-02-18 14:13:54 -08:00
Bruce Johnson
9ef377a0ad Fix issue #11320. WindowsLikeFilesystem true when release string includes case insensitive word microsoft. 2021-02-15 16:03:11 -08:00
Jan Dvorak
5f59a6ad15 Bump to Node 14.15.1 to include security patch
Bumps to latest Node 14 version to include October security patch & bumps minimum node versions in dev bundle and boot.
2020-11-25 14:24:57 +01:00
Filipe Névola
f80ae8205d Adds support to override mongo options via Meteor settings (#10976)
* Adds support to mongo options via Meteor settings
The options are in the `packages` key in the `mongo` key that is the package name. We should use the pattern every time we need a setting in a package.
2020-04-17 13:04:35 -04:00
Ben Newman
cb58f9af85 Require Node.js 12 when running Meteor 1.9 apps.
We haven't always updated this minimum version when we've changed the
Node.js version bundled with Meteor, which is fine because most deployment
strategies (including Galaxy) use the right version of Node.js
automatically. With Meteor 1.9 and Node.js 12.14.0, however, it seems
important that we make absolutely sure new Meteor apps are not getting run
in production with an end-of-life'd version of Node.js (v8).
2020-01-02 11:38:21 -05:00
Ben Newman
769337551e Convert tools/tool-env/profile.js to TypeScript.
Unfortunately, this conversion triggered an error due to one of the
shortcomings of the Babel implementation of TypeScript:

SyntaxError: /tools/tool-env/profile.ts: Namespace not marked type-only declare. Non-declarative namespaces are only supported experimentally in Babel. To enable and review caveats see: https://babeljs.io/docs/en/babel-plugin-transform-typescript
  278 | }
  279 |
> 280 | export namespace Profile {
      |                  ^
  281 |   export let enabled = !! process.env.METEOR_PROFILE;
  282 |
  283 |   export function time<TResult>(bucket: string, f: () => TResult) {
    at File.buildCodeFrameError (/Users/ben/meteor/dev_bundle/lib/node_modules/@babel/core/lib/transformation/file/file.js:261:12)
    at transpileNamespace (/Users/ben/meteor/dev_bundle/lib/node_modules/@babel/plugin-transform-typescript/lib/namespace.js:25:25)
    at PluginPass.TSModuleDeclaration (/Users/ben/meteor/dev_bundle/lib/node_modules/@babel/plugin-transform-typescript/lib/index.js:271:32)
    at newFn (/Users/ben/meteor/dev_bundle/lib/node_modules/@babel/traverse/lib/visitors.js:193:21)
    at NodePath._call (/Users/ben/meteor/dev_bundle/lib/node_modules/@babel/traverse/lib/path/context.js:53:20)
    at NodePath.call (/Users/ben/meteor/dev_bundle/lib/node_modules/@babel/traverse/lib/path/context.js:40:17)
    at NodePath.visit (/Users/ben/meteor/dev_bundle/lib/node_modules/@babel/traverse/lib/path/context.js:88:12)
    at TraversalContext.visitQueue (/Users/ben/meteor/dev_bundle/lib/node_modules/@babel/traverse/lib/context.js:118:16)
    at TraversalContext.visitMultiple (/Users/ben/meteor/dev_bundle/lib/node_modules/@babel/traverse/lib/context.js:85:17)
    at TraversalContext.visit (/Users/ben/meteor/dev_bundle/lib/node_modules/@babel/traverse/lib/context.js:144:19)
2019-07-06 09:18:35 -04:00
Ben Newman
8a409d196c Convert mini-files.js to TypeScript. 2019-07-04 14:43:51 -04:00
Ben Newman
9b01729c79 Use reify/lib/parsers/babel rather than acorn.
Acorn seems to have trouble parsing code that @babel/parser parses
successfully, such as the dist/esm.js file in markdown-to-jsx@6.10.2.
2019-07-03 10:03:28 -04:00
Ben Newman
f7f36bb758 Use default parser for Reify Module.prototype._compile hook.
This saves us from having to install @babel/parser in the server bundle.

There is currently a bug in Reify that prevents it from loading this
parser by default, but we can work around that on the Meteor side for now.
2019-07-02 15:31:16 -04:00
Ben Newman
0c5cb13136 Ensure all code evaluated by Node is compiled with Reify. 2019-07-02 13:15:46 -04:00
Ben Newman
28d74dcc9f Use Reify to compile dynamic import(...). 2019-05-15 19:12:09 -04:00
Ben Newman
114a348bb3 Convert programs/server/debug.js to TypeScript.
Another tiny module (like tools/isobuild/css-modules.ts) that proves we
can use TypeScript in programs/server/* code.
2019-04-26 18:55:08 -04:00
Ben Newman
c9ba0f3a22 Install latest Reify runtime in programs/server/main.js.
Also updated meteor-babel in the dev bundle to depend on reify@0.18.1, to
be consistent with the version used by server code.
2019-04-26 18:55:08 -04:00
Ben Newman
59c66baa9b Convert tools/static-assets/server/mini-files.js to module. 2019-04-23 19:21:57 -04:00
Ben Newman
a96241911a Address review feedback from @glasser. 2019-02-04 14:22:29 -05:00
Ben Newman
312d06a90a Add gitRevision property to star.json and __meteor_runtime_config__.
This information is useful when you need a unique identifier for the
current version of the application (and you're using Git).

If the current Git HEAD revision can't be found for any reason, the
gitRevision property simply will not appear in star.json or
__meteor_runtime_config__.
2019-02-04 11:51:38 -05:00
Ben Newman
8310870c44 Tolerate clientJson.clientArchs in dynamic-import boot.js setup. 2018-07-04 10:15:26 -04:00
Simon Schick
b3470fd0ab Added back the possibility to use IstanbulJS as plugin (#9494)
These changes are needed to get the plugin meteor-coverage working. IstanbulJS (shipped with meteor-coverage), can only generate the coverage-report for the code loaded after it's initialization. This is why the code, the plugin meteor-coverage contains, must be executed before the code is loaded, which should be tracked in the code-coverage. A suitable check I found was when a debugger isn't used, which makes it impossible to use code-coverage and the debugger at the same time. It's the only feasible condition I could come up with.

The package meteor-coverage also registers a hook of IstanbulJS which overwrites `vm.runInThisContext()` in order to start the coverage. As of now, IstanbulJS does not support overwriting `vm.Script.runInThisContext()`.
2018-01-09 11:13:48 -05:00
Ben Newman
a7585da87c Bump MIN_NODE_VERSION to enforce Node >= 8 in production. (#9485)
Clearly we haven't remembered to bump this version for some time now,
which is too bad, because it could have provided a more helpful error for
developers using an older version of Node in their non-Galaxy deployment
environments: https://github.com/meteor/meteor/issues/9470
2017-12-19 13:10:54 -05:00
Ben Newman
a33ac61ea8 Remove underscore import from boot.js. 2017-11-06 16:55:31 -05:00
Ben Newman
87ebeec54b Detect inspector client attachment by timing debugger keyword. (#9172)
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.
2017-10-03 12:11:21 -04:00
Ben Newman
eec8a1f8e9 Merge branch 'devel' into release-1.6 2017-09-18 17:25:11 -04:00
Ben Newman
e59e0a582a Convert \s to /s in Npm.require'd module identifiers.
This is another way of addressing the problem I attempted to fix with
f34c5ec926 earlier today.

Apparently, older versions of compiler plugin-registering packages such as
standard-minifier-css and templating-compiler still depend on older
versions of the meteor package, which may still use path.join to import
fibers/future. This can be fixed by republishing those packages, as I did
in 917b01ac5f, but I'd prefer not to
republish every compiler plugin package.

Fortunately, we can also solve the problem by being more tolerant in the
implementation of Npm.require, which is what this commit does.
2017-09-18 16:54:23 -04:00
Ben Newman
7ebf9b3497 Merge branch 'devel' into release-1.6 2017-09-18 12:45:34 -04:00
Ben Newman
971d2b1272 Standardize Npm.require exceptions and limit lookup paths. (#9095)
Ever since Meteor 1.3 first introduced a module system based on something
other than `Npm.require`, we've continued throwing missing module
exceptions that refer to `Npm.depends` and/or `Npm.require`, even if the
developer called `require` or used an `import` declaration. This commit
fixes that, so that all missing module exceptions look like 'Cannot find
module "module/name"'.

I also noticed recently that `Npm.require` is capable of returning modules
installed in `node_modules` directories completely outside the app, which
is bad news for development/production reproducibility. Fixed that too.

CC @hwillson who has spoken of deprecating `Npm.require` entirely, and
just using `require` everywhere, instead.
2017-09-18 11:39:45 -04:00
Ben Newman
ab338d6cd8 Don't call meteorDebugFuture.wait() unless METEOR_INSPECT_BRK is set.
Bug fixed: we should never be calling meteorDebugFuture.wait() in
production, so we now use process.env.METEOR_INSPECT_BRK in developement
to enable the waiting.

Lesson learned: if you call Fiber.yield() in the only running Fiber
without any other events scheduled on the event loop, the program will
immediately exit with code 0, as it should.

Closes #8817.
2017-06-19 14:32:52 -04:00
Ben Newman
85ee23cfa5 Stop using Object.create to clone process.env in npm-rebuild.js.
Fixes #8808.
2017-06-19 12:29:13 -04:00
Ben Newman
8550412bb0 Reimplement meteor debug using the Node 8 inspector.
This is the feature that excites me most about Meteor 1.6, hands down.

Benefits include:

* Works with `meteor test[-packages] --debug-port 9229` (for tests), as
  well as just `meteor debug` (for apps).

* The application process waits patiently for the debugger to attach, so
  you don't have to race to open the debugger.

* The application process pauses at a location just after all server code
  has been evaluated, but before any code starts executing, giving you a
  chance to set reliable breakpoints anywhere in server code. This is much
  better than using the `node --inspect-brk` flag, since that stops too
  soon to set any useful breakpoints.

* The application server runs at full speed, so you don't have to wait
  forever to hit that all-important breakpoint, and you don't lose nearly
  as much time if you accidentally continue past the line of code where
  the trouble is occurring.

* Even if your application is stuck in an infinite loop, you can still
  attach the debugger, pause execution, and debug the loop.

* No more `node-inspector`! Instead, you can now debug your server code in
  native Chrome DevTools, or several other high-quality inspector clients,
  such as VS Code or WebStorm (seriously, check out the documentation:
  https://nodejs.org/en/docs/inspector/#inspector-tools-clients). The list
  of debuggable processes can be found at the URL chrome://inspect.

* Realistic performance and memory profiling is now possible via the
  familiar DevTools interface.

* I highly recommend this Chrome extension that automatically (re)connects
  to any open inspector sockets, so you don't have to keep manually
  (re)attaching the debugger: http://june07.com/nim

* The implementation of `meteor debug` no longer has to proxy multiple
  private/public debugger ports. Look at all that deleted code!

This new inspector is so much better than the old `node-inspector` that
I've been using the release-1.6 branch to debug problems in Meteor 1.5,
despite the risks of using Node 8, because those risks are so far
outweighed by the quality of the new debugging experience.

That said, the experience isn't perfect (yet). I welcome your feedback on
the Meteor 1.6 PR: https://github.com/meteor/meteor/pull/8728
2017-06-14 19:08:40 -04:00
Jesse Rosenberger
f244a5b0c6 Change runInThisContext to Script.prototype.runInThisContext. (#8771)
This actually changed ages ago, in Node.js 0.11 via
fd3657610e
however the descriptive error message, which was previously
enabled with `true` as the third argument, was silently lost.

This reimplements the descriptive error message as mentioned in
https://github.com/meteor/meteor/issues/3200#issuecomment-289685677 by
@d-schiffner.
2017-06-08 18:07:04 -04:00
Ben Newman
5cf603ce82 Merge branch 'release-1.4.3.x' into release-1.5 2017-03-27 15:37:11 -04:00
Jesse Rosenberger
6bbd432081 Be more understanding of Windows' filesystem limitations.
Presently, the renaming of directories that are in-use will fail on
Windows.  This is already compensated for when `process.platform` is
set to `win32`.  However, within BashOnWindows/WSL (Windows Subsystem
for Linux), `process.platform` is equal to `linux`, though the
underlying filesystem is still the same.

Microsoft has stated that it is unlikely that they will remove
`Microsoft` from the `os.release()` value so we check for that.
2017-03-22 20:35:43 +02:00
Ben Newman
158adc48e8 Expose manifest of dynamic modules to the dynamic-import package. 2017-02-07 16:17:44 -05:00
Ben Newman
22d1b3ddfe Make special arguments in boot.js more configurable.
Currently this functionality is only used for exposing npmRequire and
Profile to the packages/modules-runtime.js bundle, but I'm planning to use
it for packages/dynamic-import.js soon.
2017-02-07 16:17:43 -05:00
Hugh Willson
c55d8cca76 Revert "Revert "Merge pull request #7963 from hwillson/issue-5626" (#8118)"
This reverts commit 5754f8ef3e.
2016-11-30 20:28:21 -05:00
Ben Newman
5754f8ef3e Revert "Merge pull request #7963 from hwillson/issue-5626" (#8118)
This reverts commit 11ce2f7bbc, reversing
changes made to dfde4146f7.
2016-11-30 19:48:19 -05:00
Ben Newman
11ce2f7bbc Merge pull request #7963 from hwillson/issue-5626
Load `program.json` using the Unicode Normalization Form of the loaded JSON string
2016-11-29 18:22:00 -05:00
Hugh Willson
c93756a710 Moved common normalize code into mini-files.js; Added/adjusted tests. 2016-11-03 13:57:17 -04:00
Ben Newman
19fdc5c65f Make npm-rebuild.js more Windows-friendly.
Fixes #8007.
2016-11-03 10:25:55 -04:00
Hugh Willson
d74c7b68ce Updated the Assets API to make sure assetPath strings are normalized (to address issue #5626). 2016-11-03 07:44:12 -04:00