Summary:
^
This is an effort to capture and log these errors as to gain visibility when failures occur.
Reviewed By: passy
Differential Revision: D37412861
fbshipit-source-id: 09687a31797aac4c377aa98944ab0701bdf45466
Summary:
There's one setting: to enable or disable flipper-server.
However, I've added some current running state to it. If there's a better way of doing this, please do let me know.
Reviewed By: aigoncharov
Differential Revision: D37276670
fbshipit-source-id: f6c941cf0cfe55c267b9bcb9f799934fba1e28ef
Summary:
This change attaches our event handlers as soon as the ws is created.
As a consequence, we need to wait until the server has created any necessary instances required to process incoming requests.
To achieve this, I created a type called `Lazy`.
This type wraps around a value and a promise to that value. Callers can check if the value is set. If not, callers can wait for it.
Ultimately, the value can be set outside of the promise itself.
Reviewed By: passy
Differential Revision: D37284939
fbshipit-source-id: 17dec548d7155a3d65440c9584cec07cbb826c37
Summary:
This changes moves most of the functionality found in flipper-server to flipper-server-core.
flipper-server will mostly be a package that wraps around flipper-server-core. Staying in flipper-server:
- Command line args
- Orchestration to start the necessary servers
Reviewed By: aigoncharov
Differential Revision: D36807087
fbshipit-source-id: f29002c7cc5d08b8c5184fdaaa02ba22562a9f45
Summary:
This change extracts logging logic out from startFlipperServer.
Logs will also be written to disk.
Reviewed By: passy
Differential Revision: D36473768
fbshipit-source-id: b1df9df79b4aced0d3ba2e8c243aa8d44cf83703
Summary:
These are utility methods that are not specific to startServer.
They will be reused by other components needing to check if something is listening to a port.
Make socket path is also extracted.
Reviewed By: passy
Differential Revision: D36473641
fbshipit-source-id: 73ed67912052896696b59670cb757d22761eeaa1
Summary: Allows to attribute errors to flipper server or flipper electron
Reviewed By: passy
Differential Revision: D36698504
fbshipit-source-id: 6d07216fd05aa48b7c8cca5b53145916b64526eb
Summary:
^
flipper-server verifies the origin of incoming connections as a way of preventing any host from connecting to flipper.
That's good.
This change expand the list of allowed origins to include localhost:3000 which is the default origin for Electron apps.
Error without this change:
```
Refused socket connection from cross domain request, origin: http://localhost:3000, host: localhost:52342. Expected origins: http://localhost:52342 or http://[::1]:52342 or http://::1:52342. Expected hosts: localhost:52342 or [::1]:52342 or ::1:52342
```
Reviewed By: passy
Differential Revision: D36440363
fbshipit-source-id: 883cadb49f245bca5d0a53a4f58c08cf45dd0189
Summary:
Currently, Flipper Server has a few productions dependencies (mac-ca, node-fetch) that are not bundled with the Flipper Server. It makes it harder to distribute Flipper Server, as now all potential consumers need not only to download the bundle, but also install these additional dependencies.
This diff makes it possible to bundle `mac-ca` and `node-fetch` with Flipper Server. As a result, Flipper Server becomes dependency-free in production.
Reviewed By: lblasa
Differential Revision: D36345213
fbshipit-source-id: 2cd6ba1b3301b45dc2295891964ba020fd107586
Summary:
Same as with the previous diff.
The function doesn't really start a server. Instead it attaches the routing of messages from the existing server into FlipperServer.
Reviewed By: passy
Differential Revision: D36310703
fbshipit-source-id: 7ac9a742fb36c3806597382c9aadcf96f4770484
Summary:
^
Instead of 'start' use 'attach' as it seems closer to what the function actually does.
Reviewed By: passy
Differential Revision: D36310846
fbshipit-source-id: db90efc6ec3207b1a5a38139a3ba01d2f7d2aebd
Summary:
^
BaseServer doesn't really have any meaning. So, change it to just Server as it really creates the Express app and HTTP server attached to it.
Reviewed By: passy
Differential Revision: D36310822
fbshipit-source-id: eee5a2a395ca726679c1c4756ed58d4bc6be3cb8
Summary:
Rename 'startWebServerDev' to just 'startDevServer'.
It isn't really starting a web server though, more like installing routings and middleware to the existing created server.
Reviewed By: passy
Differential Revision: D36310765
fbshipit-source-id: 0af772012525fd7ad19e2aa6fa73cb3e7dcf2bef
Summary: Slight changes to the URL and port logging.
Reviewed By: passy
Differential Revision: D36310796
fbshipit-source-id: 553b9ce932792c471f8e0e2c1a0c7d79897ad59d
Summary: These safeguards were added based on a discussion in D35088208 (56e94394ca) but turned out to be counter-productive. Every time a client disconnects now, we're tearing down the socket and the server, allowing for no future connections.
Reviewed By: lblasa
Differential Revision: D36252605
fbshipit-source-id: c3b6f85dea4054505a47d24a72a4aac403371c0f
Summary: Start flipper-server-companion whenever a client connects to flipper-server and sets `server_companion` query parameter in a connection URL to true
Reviewed By: mweststrate
Differential Revision: D36098169
fbshipit-source-id: eb953e7d680b30aef1340f059264112387264c05
Summary:
Before:
```
flipper-server/src/startBaseServer.tsx(222,30): error TS2345: Argument of type 'string | undefined' is not assignable to parameter of type 'string'.
Type 'undefined' is not assignable to type 'string'.
flipper-ui-browser/src/flipperServerConnection.tsx(25,9): error TS2322: Type 'Timeout' is not assignable to type 'number'.
```
Reviewed By: nikoant
Differential Revision: D36100188
fbshipit-source-id: 1913a43109a0e068394a188d362f6a9e473e7904
Summary: Be more aggressive in cleaning up after ourselves. Using a tiny library by Sindre that handles standard exit events, SIGTERM and SIGINT.
Reviewed By: aigoncharov
Differential Revision: D35281772
fbshipit-source-id: a789f90f172b3aa3e187739cf2b7fefa75405891
Summary: lawrencelomax helpfully pointed out that there's a legacy limit for the path length of unix domain sockets. Checking here and falling back to `/tmp` in case we're going over. This could have caused some gnarly support issues, so I'm glad we caught this before it went live.
Reviewed By: aigoncharov
Differential Revision: D35257794
fbshipit-source-id: 68a7b62d6d6863efa4b3ce84d7735b1c1a45a174
Summary: Instead of just deleting, we first check if it's already in use. The behaviour in case it *is* in use, is not great but mirrors what happens when the port is occupied.
Reviewed By: aigoncharov
Differential Revision: D35188965
fbshipit-source-id: 9bb5a7a9bacec6987ea72bbd084e40d5b30f9796
Summary: Open a domain socket by default and proxy all browser requests via TCP to it. That allows us to connect to a running server regardless of its local port.
Reviewed By: aigoncharov
Differential Revision: D35088208
fbshipit-source-id: d167852162e63f68c804c379b4421f5cc0d33df2
Summary: Add a simple endpoint to the server to check if it's up and running.
Reviewed By: aigoncharov
Differential Revision: D35087344
fbshipit-source-id: ec490fdb11042e7a7e4b9b944b018c4c9853ed49
Summary:
Another kind of error that can easily be triggered during testing that will kill the server otherwise.
Changelog: Make it possible to recover from malformed JSON in server requests
Reviewed By: timur-valiev
Differential Revision: D34932896
fbshipit-source-id: 7c6acfd53ffbd85a54a786d74c99bcccb64d85cb
Summary: Following up on D34787674 (f85def32fb).
Reviewed By: aigoncharov
Differential Revision: D34930249
fbshipit-source-id: f209a638c1281957fd2b03b6fc50389bd98bc5f6
Summary:
There appears to be an issue with login on M1 Macs right now. To address this, this resolves the native binary based on a `(platform, arch)` tuple.
The binaries are from here: https://github.com/atom/node-keytar/releases/tag/v7.9.0
The binary size increase here is notable so as a follow-up we could remove the non-relevant binaries as part of the packing process.
Reviewed By: aigoncharov
Differential Revision: D34685236
fbshipit-source-id: d860a59517a769a59055dfca24d01baecd8d1430
Summary: Socket.io-client sends the host as ::1 instead of [::1] when using IPV6 to communicate with Flipper, that is the reason the communication was always being refused.
Reviewed By: mweststrate
Differential Revision: D34679825
fbshipit-source-id: b7431ad23f743276c11619d7cdb5c83594dee43a
Summary: Add support for binding the same port in flipper in both the IPv6 and IPv4 interfaces
Reviewed By: mweststrate
Differential Revision: D34591022
fbshipit-source-id: e28239c24425885ee442d93b84bb38902d521a0c
Summary: This change gives priority to a user option settingsString to set up the flipper-server configuration and load them from a json string. Also giving the user the chance to avoid flipper-server looking at the launcher config files in the computer
Reviewed By: mweststrate
Differential Revision: D34210110
fbshipit-source-id: 9e852b79da106b5140c59116fd7d0c0f3155e620
Summary:
This diff makes sure that errors are propagated similarly in flipper desktop and browser version, and that they are shown in either case.
Since in the browser version, the UI loads after the error happened, we'll store the error so that any client connecting in the future will read and report it.
Also added a `--failFast` flag to flipper-server, so that the process exits immediately if misconfigured, which is convenient in CI use cases and such
Reviewed By: nikoant
Differential Revision: D33348922
fbshipit-source-id: 0f584104f881141fde38da3f0031748415343ea2
Summary:
This refactors the flipper-server release script in such a way that it works the same as the normal release script, which solves two problems:
1) the official release script modifies versioned files, as it touches the package.json
2) it was slightly confusing that `flipper-server/static` was filled for release builds only, but not used in dev builds
3) running test:npx without running a release build before it, would fail with hard to comprehend errors. this has been solved now by removing that script and make it an arg of `build:flipper-server`
Also some further minor changes to prepare running a corresponding build / release job from SandCastle (later in this stack)
Reviewed By: nikoant
Differential Revision: D33297214
fbshipit-source-id: f6299aa982c3e59d1cc6479a93c56cbe4b57f85c
Summary:
This diff fixes several issues around loading plugin, such as:
* make suresource maps work in the flipper-server production build
* make sure default plugins are no symlinked, which wouldn't work anywhere else but on the the system where it was build
* support release channel param for flipper-server
Bundled flipper-server is now 42MB (with icons (see later diffs) and plugins
```
ll flipper-server-v0.0.0.tgz
-rw-r--r-- 1 mweststrate staff 42M 23 Dec 15:29 flipper-server-v0.0.0.tgz
```
Reviewed By: nikoant
Differential Revision: D33294677
fbshipit-source-id: 63538dc8127f883fee6a3608673ad11ce239b350
Summary: Make sure flipper-server is bundled in such a way that it is self-contained NPX-able. Also added some checks to make sure that dev dependencies don't accidentallly end up in in Flipper buidls
Reviewed By: nikoant
Differential Revision: D33190254
fbshipit-source-id: 443162e537d8ca9f956acac2d7bd52cbf0c92172
Summary:
This diff makes flipper-server stand-alone servable as a single package.
It basically works as follows:
- (default) plugins are build as usually into static folder
- static folder is copied into flipper-server/static (as far as relevant)
- `flipper-server/src/index.tsx` is bundled into `flipper-server/dist/index.js`
- `flipper-ui-browser/src/index.tsx` is bundled into `flipper-server/static/bundle.js`
If flipper-server is started without the `--bundler` config, the `bundle.js` will be served statically, rather than starting up the Metro bundler with all the typical transforms (in a distributed version of the package those all wouldn't resolve)
Things to be done in next diffs:
* make sure plugins actually load in the non bundled setup
* make sure flipper-server gets published properly
* make sure build is created as part of CI
At the end of this stack, running `npx flipper-server` on any machine should basically be a viable approach to get flipper up and running locally :)
Reviewed By: nikoant
Differential Revision: D33171107
fbshipit-source-id: 4af8ac2699467a0b55283fe084640482700744c2
Summary: This diff is some boyscouting on cleaning up our globals, and stop using them inconsistently icmw global or window
Reviewed By: aigoncharov
Differential Revision: D33171108
fbshipit-source-id: 400893e5f31523631a7ab6fda428524c751901f1
Summary:
This diff removes most deps from the root package.json, which now only contains electron and shared build / test infra structure: lint, prettier, jest, typescript.
This makes it possible to control much better which packages are used where, as all sub packages now have their deps explicitly in their package.json instead of incidentally shared. This allows for example to disable DOM types for all packages by default (flipper-plugin, ui(-core) and app still request it), and in the next diff I hope to add to this that nodeJS types are no longer shared either, so that UI oriented packages will generate compile errors when using Node built-ins
This diff removes most deps that were currently unused, and dedupes a bunch of other ones, so the build should probably be a bit smaller now as well:
{F686704253}
{F686704295}
Reviewed By: antonk52
Differential Revision: D33062859
fbshipit-source-id: 5afaa4f2103d055188382a3370c1fffa295a298a
Summary:
Bundled plugins so far didn't load because the defaultPlugins was not generated yet. Fixed follow up errors that resulted from node modules not being available in the browser, and made the process more robust so that one plugin that fails to initialise doesn't kill all bundled plugins from being loaded.
Cleaned up the server scripts, and reused the BUILTINS list that is already maintained in the babel transformer.
Report errors during the build process if modules are referred that are stubbed out (later on we could maybe error on that)
Reviewed By: aigoncharov
Differential Revision: D33020243
fbshipit-source-id: 3ce13b0049664b5fb19c1f45f0b33c1d7fdbea4c
Summary: Make sure the flipper server socket only accepts local connections
Reviewed By: aigoncharov
Differential Revision: D33020251
fbshipit-source-id: 53e95e4871a45f3a3fa14f999499568a5a6b4995
Summary: Removed process, adbkit and electron usages that were still remaining. Verified changes by disabling the built-in module stubbing (will be cleaned up further later in this stack).
Reviewed By: aigoncharov
Differential Revision: D33019083
fbshipit-source-id: 8bfce31f4b5ed349cb4fd86d34c9b41b9b8b8360
Summary: During startup the socket connection would close a few times, among others because Scribe dumps 1.3 MB of data after startup, and the maximum payload of `socket.io` defaults to 1MB. This diff changes it to 100MB (the max size used by `ws` library). We know that we need at least > 10 MB, as that is what plugins like Network cap at.
Reviewed By: aigoncharov
Differential Revision: D33017653
fbshipit-source-id: 1233af6fbdc4b9eed42786ee418cfd6d43b2b433
Summary: This diffs adds debugging support to flipper server, by adding VSCode config for it
Reviewed By: timur-valiev, aigoncharov
Differential Revision: D32982874
fbshipit-source-id: 8e187ad05a05566a598db04b97e8b08e3de7e835
Summary:
The build process for the server was a simple ts-node that compiled all deps. However, that didn't do any source transformations we need, like replacing `fb-stubs` with `fb` in facebook builds.
This diff works out the dev build process to align more with how other parts of the code base is build, by starting metro to build and bundle the server (only the sources of flipper-server, flipper-server-core and other flipper packages are bundled, node-deps are left as is).
To achieve this, since metro doesn't have support for 'external' packages like any arbitrarily other bundler, we recycle the electronRequire work around that is used in the desktop app as well
Reviewed By: aigoncharov
Differential Revision: D32949677
fbshipit-source-id: 00d326bb17b68aece6fb43af98d0def13b335e74
Summary: Per title, processed some pending review comments made earlier in this stack
Reviewed By: aigoncharov
Differential Revision: D32916920
fbshipit-source-id: 01db85883596b5c85b77efc9cddadeac23cc4ef5