-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Conversation
… path by adding a unique filterRequest identifier.
Oops. Accidentally closed. |
Assigned to me |
@@ -68,8 +75,8 @@ | |||
|
|||
/** | |||
* @private | |||
* @type {Object.<string, {Object.<string, http.ServerResponse>}} | |||
* A map from root paths to its request/response mapping. | |||
* @type {Object.<number, {Object.<string, http.ServerResponse>}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this right? Looking at the usage it should be {Object.<string, {Object.<number, function>}}
and A map from root paths to its request to reponse callback mapping.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Er, right, good catch. I'll fix that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you make this change? I don't see it.
Interesting. I just happened to have an open live preview session in Brackets when I ran the |
Was there any reason besides time to not update the other usages of |
_nodeConnectionDeferred.reject(); | ||
} | ||
); | ||
return _nodeDomain.promise().then(function () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't seem necessary to wait for the promise here anymore. Is it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe not? I wasn't quite sure, so I opted to try to preserve the existing functionality. Everything is so delicate with live development, so when in doubt I just tried not to shake anything. If you don't think it's necessary though I could also kill that promise()
method...
Initial review complete @iwehrman. Nice work. |
The only reason I didn't convert more |
This doesn't need to land for sprint 35 right? We talked at the standup that this would land in sprint 36. |
It does not need to land in Sprint 35. Ideally it would land before the file watchers/caching stuff so we can use it in |
Ready for re-review. I removed the |
I'll add this to sprint 36. |
Re-review complete. Just some minor questions. |
Should be ready to go now. |
Merging. |
This is awesome btw! Great cleanup. Have we filed a spinoff bug/story for porting over our other NodeConnection usages? |
This pull request has three parts:
NodeDomain
module, which is a high-level wrapper aroundNodeConnection
. This makes it easy to open a connection and load a single domain, and then execute the domain's commands and listen for its events. The wrapper handles, in particular, connection and domain loading and reloading.The inline documentation gives the following usage example:
StaticServer
to useNodeDomain
instead of manipulatingNodeConnection
directly. The previous code had been copied and pasted regularly, but had a few shortcomings, including redundant timeouts (NodeConnection
handles this already), failure to handle disconnected sockets, and, in some cases, a silent fail-fast behavior on command execution where simply waiting would suffice. (If theNodeConnection
isn't connected, don't abort; just wait for it to come back up!)StaticServerDomain
that was causing theLiveDevelopment
unit tests to fail unpredictably.The problem is as follows: when
StaticServerDomain
receives an HTTP request for a filtered path, it emits afilterRequest
event to Brackets to have the file contents at that path manipulated before sending the response. Brackets later calls thewriteFilteredResponse
command with the manipulated data, which triggers the HTTP response.StaticServerDomain
connects these filtered responses to their original filter requests by way of a map of callbacks keyed on the requested paths. But, as a consequence, when theStaticServerDomain
HTTP server receives two concurrent requests for the same path, it only stores one response callback. The second filtered response is then be dropped, no longer having any response callback at the given path, and the second request---whose response callback has been overwritten---will always time out. The problem is solved here by adding a unique identifier to eachfilterRequest
and keying callbacks on this identifier.