@apmantza/greedysearch-pi 1.0.4 → 1.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/launch.mjs CHANGED
@@ -154,11 +154,16 @@ async function main() {
154
154
  // Already running?
155
155
  const existing = isRunning();
156
156
  if (existing) {
157
- console.log(`GreedySearch Chrome already running (pid ${existing}, port ${PORT}).`);
158
- // Ensure redirect is in place (idempotent)
159
157
  const ready = await writePortFile(5000);
160
- if (ready) { redirectCdpToGreedySearch(); console.log('DevToolsActivePort redirected.'); }
161
- return;
158
+ if (ready) {
159
+ console.log(`GreedySearch Chrome already running (pid ${existing}, port ${PORT}).`);
160
+ redirectCdpToGreedySearch();
161
+ console.log('DevToolsActivePort redirected.');
162
+ return;
163
+ }
164
+ // Stale PID — process alive but not Chrome on port 9223. Fall through to fresh launch.
165
+ console.log(`Stale PID ${existing} detected (not Chrome on port ${PORT}) — launching fresh.`);
166
+ try { unlinkSync(PID_FILE); } catch {}
162
167
  }
163
168
 
164
169
  const CHROME_EXE = process.env.CHROME_PATH || findChrome();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apmantza/greedysearch-pi",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
4
4
  "description": "Pi extension: search Perplexity, Bing Copilot, and Google AI simultaneously — synthesized AI answers, not just links",
5
5
  "type": "module",
6
6
  "keywords": [
package/search.mjs CHANGED
@@ -116,7 +116,7 @@ async function closeTab(targetId) {
116
116
  } catch { /* best-effort */ }
117
117
  }
118
118
 
119
- function runExtractor(script, query, tabPrefix = null, short = false) {
119
+ function runExtractor(script, query, tabPrefix = null, short = false, timeoutMs = 90000) {
120
120
  const extraArgs = [
121
121
  ...(tabPrefix ? ['--tab', tabPrefix] : []),
122
122
  ...(short ? ['--short'] : []),
@@ -129,7 +129,12 @@ function runExtractor(script, query, tabPrefix = null, short = false) {
129
129
  let err = '';
130
130
  proc.stdout.on('data', d => out += d);
131
131
  proc.stderr.on('data', d => err += d);
132
+ const t = setTimeout(() => {
133
+ proc.kill();
134
+ reject(new Error(`${script} timed out after ${timeoutMs / 1000}s`));
135
+ }, timeoutMs);
132
136
  proc.on('close', code => {
137
+ clearTimeout(t);
133
138
  if (code !== 0) reject(new Error(err.trim() || `extractor exit ${code}`));
134
139
  else {
135
140
  try { resolve(JSON.parse(out.trim())); }