Skip to content

Commit 92b3bfc

Browse files
pwassmclaude
andcommitted
dev1003: proxy 0xC0000409 hunt - the Sept 16-17 silent deaths had 16GB+ COMMIT free, so dev0697's commit story doesn't cover them (proxy.log.1: 0 deaths in 4,481 probes Sept 8-16; since dev0992: 5 in ~3,900, three within ~0.2s of "embed probe start", each right after a Node TLS cover/carousel download). Instrument: proxy.crumb - every IG fetch step (get/dns/tcp/tls/hdr/body/close), cffi + yt-dlp spawn/close, ffprobe, publish and request start rewrites the last 16 steps synchronously; the next START after a crash prints them to proxy.log. Embed probe done line now carries step ms + negotiated TLS/group. Mitigation: one shared tls SecureContext for the cookieless IG fetches + probe (was a new OpenSSL SSL_CTX per connection, freed later by GC - nodejs/node#66002); ClientHello, fresh socket per request and no session resumption unchanged. IG_TLS_SHARED=false reverts it. Startup 0xC0000409 text no longer asserts commit exhaustion. PROXY RESTART needed.
Co-Authored-By: Claude Opus 5 <[email protected]>
1 parent 4183a68 commit 92b3bfc

4 files changed

Lines changed: 137 additions & 24 deletions

File tree

‎.gitignore‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,8 @@ logs
153153
# extension — so an 8MB rotated proxy log was sitting in `git status` waiting to be
154154
# committed by accident (the same trap as the ig.json.bak* rule above).
155155
*.log.[0-9]*
156+
# (dev1003) proxy.js crash breadcrumbs, rewritten on every IG fetch/spawn step.
157+
proxy.crumb
156158
npm-debug.log*
157159
yarn-debug.log*
158160
yarn-error.log*

‎igEmbedProbeCore.js‎

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,29 +38,50 @@ const DEFAULTS = {
3838
cffiTimeoutMs: 40000,
3939
track: null, // Set-like (proxy's ACTIVE_DL) so the VPN kill-switch can SIGKILL
4040
saveHtmlTo: null, // dir → dump the fetched HTML (calibration only)
41+
// (dev1003) Both optional; the overnight script passes neither and behaves as before.
42+
secureContext: null, // shared tls SecureContext — no per-probe OpenSSL SSL_CTX build/GC-free
43+
crumb: null, // crumb(step) — sync breadcrumb after each native step (proxy crash hunt)
4144
log: null
4245
};
4346

4447
let impersonateOk = null; // null=untried false=curl_cffi missing (stop spawning)
4548

49+
// (dev1003) `t` = ms from the GET to each step (dns/tcp/tls/hdr/body) and `tls` = the
50+
// negotiated protocol/key-exchange group — what a normal probe's first ~200ms looks like,
51+
// for comparison with the three deaths that happened inside that window.
4652
function fetchNode(url, o) {
4753
return new Promise(resolve => {
54+
const crumb = o.crumb || (() => {});
4855
const opts = { agent: false, headers: {
4956
'User-Agent': SHORT_UA,
5057
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
5158
'Accept-Language': 'en-US,en;q=0.9',
5259
'Referer': url.replace(/embed\/captioned\/?$/, ''),
5360
'Connection': 'close'
5461
} };
55-
let h = '';
62+
if (o.secureContext) opts.secureContext = o.secureContext;
63+
const t0 = Date.now(), t = {};
64+
let h = '', tls = '';
65+
const done = v => { v.t = t; v.tls = tls; resolve(v); };
66+
crumb('get');
5667
const req = https.get(url, opts, r => {
57-
if (r.statusCode !== 200) { r.resume(); resolve({ status: r.statusCode, html: '' }); return; }
68+
t.hdr = Date.now() - t0; crumb('hdr ' + r.statusCode);
69+
if (r.statusCode !== 200) { r.resume(); done({ status: r.statusCode, html: '' }); return; }
5870
r.setEncoding('utf8');
5971
r.on('data', c => { h += c; if (h.length > 4e6) req.destroy(); });
60-
r.on('end', () => resolve({ status: 200, html: h }));
72+
r.on('end', () => { t.body = Date.now() - t0; crumb('body ' + h.length); done({ status: 200, html: h }); });
6173
});
62-
req.on('error', () => resolve({ status: 0, html: '' }));
63-
req.setTimeout(o.nodeTimeoutMs, () => { req.destroy(); resolve({ status: -1, html: '' }); });
74+
req.on('socket', s => {
75+
s.once('lookup', () => { t.dns = Date.now() - t0; crumb('dns'); });
76+
s.once('connect', () => { t.tcp = Date.now() - t0; crumb('tcp'); });
77+
s.once('secureConnect', () => {
78+
t.tls = Date.now() - t0;
79+
try { const k = s.getEphemeralKeyInfo() || {}; tls = (s.getProtocol() || '?') + '/' + (k.name || k.type || '?'); } catch (_) {}
80+
crumb('tls ' + tls);
81+
});
82+
});
83+
req.on('error', () => done({ status: 0, html: '' }));
84+
req.setTimeout(o.nodeTimeoutMs, () => { req.destroy(); done({ status: -1, html: '' }); });
6485
});
6586
}
6687

@@ -69,6 +90,7 @@ function fetchImpersonated(url, o) {
6990
if (impersonateOk === false) { resolve({ status: 0, html: '' }); return; }
7091
const tmp = path.join(o.scratch, '.probe_' + Date.now().toString(36) + Math.random().toString(36).slice(2, 7));
7192
let proc;
93+
if (o.crumb) o.crumb('cffi spawn');
7294
try {
7395
proc = spawn(o.python, [o.impersonatePy, url, tmp,
7496
url.replace(/embed\/captioned\/?$/, ''),
@@ -89,6 +111,7 @@ function fetchImpersonated(url, o) {
89111
proc.stdout.on('data', d => { out += d.toString('utf8'); });
90112
proc.on('error', () => finish(0));
91113
proc.on('close', () => {
114+
if (o.crumb) o.crumb('cffi close');
92115
const s = out.trim();
93116
if (/^ERR curl_cffi import/i.test(s)) { impersonateOk = false; if (o.log) o.log('⚠ curl_cffi missing — node-only from here'); }
94117
else if (/^\d+$/.test(s)) impersonateOk = true;
@@ -134,6 +157,8 @@ async function probeEmbed(id, opts) {
134157
const o = Object.assign({}, DEFAULTS, opts || {});
135158
const url = 'https://www.instagram.com/p/' + id + '/embed/captioned/';
136159
let r = await fetchNode(url, o);
160+
const nodeT = r.t, nodeTls = r.tls;
161+
if (o.crumb) o.crumb('markers ' + (r.html || '').length);
137162
let m = markers(r.html), via = 'node';
138163
let d = verdict(m, r.status);
139164
if (d.kind === 'wall' && o.cffi) { // walled/thin → impersonated retry
@@ -145,7 +170,8 @@ async function probeEmbed(id, opts) {
145170
if (o.saveHtmlTo) {
146171
try { fs.writeFileSync(path.join(o.saveHtmlTo, 'calib_' + id + '_' + via + '.html'), r.html || ''); } catch (_) {}
147172
}
148-
return { id, status: r.status, via, m, v: d.v, kind: d.kind };
173+
if (o.crumb) o.crumb('verdict ' + d.kind);
174+
return { id, status: r.status, via, m, v: d.v, kind: d.kind, t: nodeT, tls: nodeTls };
149175
}
150176

151177
module.exports = { probeEmbed, markers, verdict, SHORT_UA };

‎index.html‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1167,7 +1167,7 @@ <h3 style="color:#fa8;font-size:12px;margin:0 0 8px;letter-spacing:0.05em;">🐚
11671167
• the ?v= cache-buster on every script tag below
11681168
• the bottom-right ver-badge text (boot.js refreshes it on load) -->
11691169
<script>
1170-
window.HELP_VERSION_STR = 'dev1002';
1170+
window.HELP_VERSION_STR = 'dev1003';
11711171
(function() {
11721172
var v = window.HELP_VERSION_STR.replace(/^(dev|user)/, '');
11731173
// (dev0702) helpfloat.js MUST stay first: it registers the window-capture

0 commit comments

Comments
 (0)