Skip to content
This repository has been archived by the owner on Aug 31, 2023. It is now read-only.

Use createRequire with createRequireFromPath as fallback #90

Merged
merged 4 commits into from
Mar 2, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions packages/@romejs/codec-websocket/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ export async function createClient(
});

req.on('response', res => {
if (res.statusCode >= 400) {
if (res.statusCode && res.statusCode >= 400) {
process.stderr.write(`Unexpected HTTP code: ${res.statusCode}\n`);
res.pipe(process.stderr);
} else {
Expand All @@ -240,7 +240,6 @@ export async function createClient(

req.on('upgrade', (res, socket, head) => {
if (res.headers['sec-websocket-accept'] !== digest) {
res.end();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

end doesn't exist on this response type (https://nodejs.org/api/http.html#http_class_http_incomingmessage). socket.end() should be enough.

socket.end();
reject(
new Error(
Expand Down
2 changes: 1 addition & 1 deletion packages/@romejs/events/bridgeCreators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ export function createBridgeFromChildProcess<B extends Bridge>(
});

proc.on('message', msg => {
bridge.handleMessage(msg);
bridge.handleMessage(msg as BridgeMessage);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was this change necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the update of @types/node to its latest version, msg is now from type Serializable and not any anymore https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/node/child_process.d.ts#L60.

Argument of type 'Serializable' is not assignable to parameter of type 'BridgeMessage'.
Type 'string' is not assignable to type 'BridgeMessage'

Alternatively, I could change the argument type in handleMessage to make it more transparent, or revert the update of the types module if it's too much action overall for this.

});

// Catch process dying and reject any requests in flight
Expand Down