New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@react-native/dev-middleware

Package Overview
Dependencies
Maintainers
0
Versions
554
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@react-native/dev-middleware - npm Package Compare versions

Comparing version 0.79.0-nightly-20250214-b3c41cef9 to 0.79.0-nightly-20250215-103f8b388

1

dist/createDevMiddleware.js

@@ -44,2 +44,3 @@ "use strict";

experiments,
logger,
unstable_customInspectorMessageHandler

@@ -46,0 +47,0 @@ );

@@ -14,2 +14,3 @@ /**

import type { Experiments } from "../types/Experiments";
import type { Logger } from "../types/Logger";
import type { CreateCustomMessageHandlerFn } from "./CustomMessageHandler";

@@ -35,2 +36,3 @@ import type { PageDescription } from "./types";

experiments: Experiments,
logger?: Logger,
customMessageHandler: null | undefined | CreateCustomMessageHandlerFn

@@ -37,0 +39,0 @@ );

90

dist/inspector-proxy/InspectorProxy.js

@@ -35,2 +35,3 @@ "use strict";

#customMessageHandler;
#logger;
constructor(

@@ -41,2 +42,3 @@ projectRoot,

experiments,
logger,
customMessageHandler

@@ -49,2 +51,3 @@ ) {

this.#experiments = experiments;
this.#logger = logger;
this.#customMessageHandler = customMessageHandler;

@@ -141,9 +144,9 @@ }

wss.on("connection", async (socket, req) => {
const fallbackDeviceId = String(this.#deviceCounter++);
const query = _url.default.parse(req.url || "", true).query || {};
const deviceId = query.device || fallbackDeviceId;
const deviceName = query.name || "Unknown";
const appName = query.app || "Unknown";
const isProfilingBuild = query.profiling === "true";
try {
const fallbackDeviceId = String(this.#deviceCounter++);
const query = _url.default.parse(req.url || "", true).query || {};
const deviceId = query.device || fallbackDeviceId;
const deviceName = query.name || "Unknown";
const appName = query.app || "Unknown";
const isProfilingBuild = query.profiling === "true";
const deviceRelativeBaseUrl =

@@ -172,14 +175,30 @@ (0, _getBaseUrlFromRequest.default)(req) ?? this.#serverBaseUrl;

this.#devices.set(deviceId, newDevice);
this.#logger?.info(
"Connection established to app '%s' on device '%s'.",
appName,
deviceName
);
debug(
`Got new connection: name=${deviceName}, app=${appName}, device=${deviceId}, via=${deviceRelativeBaseUrl.origin}`
);
socket.on("close", () => {
socket.on("close", (code, reason) => {
this.#logger?.info(
"Connection closed to app '%s' on device '%s' with code '%s' and reason '%s'.",
appName,
deviceName,
String(code),
reason
);
if (this.#devices.get(deviceId)?.dangerouslyGetSocket() === socket) {
this.#devices.delete(deviceId);
}
debug(`Device ${deviceName} disconnected.`);
});
} catch (e) {
console.error("error", e);
socket.close(INTERNAL_ERROR_CODE, e?.toString() ?? "Unknown error");
} catch (error) {
this.#logger?.error(
"Connection failed to be established with app '%s' on device '%s' with error:",
appName,
deviceName,
error
);
socket.close(INTERNAL_ERROR_CODE, error?.toString() ?? "Unknown error");
}

@@ -202,2 +221,3 @@ });

(0, _getBaseUrlFromRequest.default)(req) ?? this.#serverBaseUrl;
const appId = this.#devices.get(deviceId)?.getApp() || "unknown";
if (deviceId == null || pageId == null) {

@@ -210,3 +230,4 @@ throw new Error("Incorrect URL - must provide device and page IDs");

}
this.#startHeartbeat(socket, DEBUGGER_HEARTBEAT_INTERVAL_MS);
this.#logger?.info("Connection to DevTools established.");
this.#startHeartbeat(socket, DEBUGGER_HEARTBEAT_INTERVAL_MS, appId);
device.handleDebuggerConnection(socket, pageId, {

@@ -216,9 +237,12 @@ debuggerRelativeBaseUrl,

});
} catch (e) {
console.error(e);
socket.close(INTERNAL_ERROR_CODE, e?.toString() ?? "Unknown error");
} catch (error) {
this.#logger?.error(
"Connection failed to be established with DevTools with error:",
error
);
socket.close(INTERNAL_ERROR_CODE, error?.toString() ?? "Unknown error");
this.#eventReporter?.logEvent({
type: "connect_debugger_frontend",
status: "error",
error: e,
error,
});

@@ -229,5 +253,6 @@ }

}
#startHeartbeat(socket, intervalMs) {
#startHeartbeat(socket, intervalMs, appId) {
let shouldSetTerminateTimeout = false;
let terminateTimeout = null;
let latestPingMs = Date.now();
const pingTimeout = (0, _timers.setTimeout)(() => {

@@ -239,2 +264,3 @@ if (socket.readyState !== _ws.default.OPEN) {

shouldSetTerminateTimeout = true;
latestPingMs = Date.now();
socket.ping(() => {

@@ -250,2 +276,12 @@ if (!shouldSetTerminateTimeout) {

socket.terminate();
this.#logger?.error(
`Connection terminated with DevTools after not responding for ${
MAX_PONG_LATENCY_MS / 1000
} seconds.`
);
this.#eventReporter?.logEvent({
type: "debugger_timeout",
duration: MAX_PONG_LATENCY_MS,
appId,
});
}, MAX_PONG_LATENCY_MS).unref();

@@ -259,5 +295,19 @@ });

};
socket.on("pong", onAnyMessageFromDebugger);
socket.on("message", onAnyMessageFromDebugger);
socket.on("close", () => {
socket.on("pong", () => {
onAnyMessageFromDebugger();
this.#eventReporter?.logEvent({
type: "debugger_heartbeat",
duration: Date.now() - latestPingMs,
appId,
});
});
socket.on("message", () => {
onAnyMessageFromDebugger();
});
socket.on("close", (code, reason) => {
this.#logger?.info(
"Connection to DevTools closed with code '%s' and reason '%s'.",
String(code),
reason
);
shouldSetTerminateTimeout = false;

@@ -264,0 +314,0 @@ terminateTimeout && (0, _timers.clearTimeout)(terminateTimeout);

@@ -87,3 +87,5 @@ /**

**/
any;
any
| { type: "debugger_heartbeat"; duration: number; appId: string }
| { type: "debugger_timeout"; duration: number; appId: string };
/**

@@ -90,0 +92,0 @@ * A simple interface for logging events, to be implemented by integrators of

{
"name": "@react-native/dev-middleware",
"version": "0.79.0-nightly-20250214-b3c41cef9",
"version": "0.79.0-nightly-20250215-103f8b388",
"description": "Dev server middleware for React Native",

@@ -26,3 +26,3 @@ "keywords": [

"@isaacs/ttlcache": "^1.4.1",
"@react-native/debugger-frontend": "0.79.0-nightly-20250214-b3c41cef9",
"@react-native/debugger-frontend": "0.79.0-nightly-20250215-103f8b388",
"chrome-launcher": "^0.15.2",

@@ -29,0 +29,0 @@ "chromium-edge-launcher": "^0.2.0",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc