MCPcopy Create free account
hub / github.com/Snapchat/Valdi / encodeWsFrame

Function encodeWsFrame

npm_modules/cli/src/utils/hermesClient.ts:118–141  ·  view source on GitHub ↗
(text: string)

Source from the content-addressed store, hash-verified

116 res.once('error', error => {
117 clearTimeout(timer);
118 fail(error);
119 });
120 res.once('end', () => {
121 if (settled) return;
122 clearTimeout(timer);
123 let body: string;
124 try {
125 body = FATAL_UTF8_DECODER.decode(Buffer.concat(chunks, bodyBytes));
126 } catch {
127 fail(new CliError(`Hermes debug server on port ${port} returned malformed UTF-8`));
128 return;
129 }
130 try {
131 const devices = JSON.parse(body) as HermesDebuggableDevice[];
132 settled = true;
133 resolve(devices);
134 } catch {
135 fail(new CliError(`Invalid response from Hermes debug server on port ${port}`));
136 }
137 });
138 });
139
140 req.on('error', (err: NodeJS.ErrnoException) => {
141 clearTimeout(timer);
142 if (err.code === 'ECONNREFUSED') {
143 fail(new NotHermesError(port));
144 } else {

Callers 1

callMethod · 0.85

Calls 3

copyMethod · 0.65
fromMethod · 0.45
concatMethod · 0.45

Tested by

no test coverage detected