@fffangchenghao/dsh-web-search 0.13.9 → 0.13.11
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/CHANGELOG.md +20 -0
- package/lib/fetch.js +8 -4
- package/lib/proxy.js +3 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.13.11
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
- **`web_fetch` failed on every request more than 25 s after a restart**
|
|
7
|
+
("no time left in the fetch budget" from the direct, tunnel and extract
|
|
8
|
+
rungs). The 25 s ladder budget was captured in the provider factory, which
|
|
9
|
+
runs once when the plugin mounts, so the deadline had already passed for any
|
|
10
|
+
later request. The budget now starts inside each `fetch()` call; a regression
|
|
11
|
+
test builds a provider, waits 1.2 s, and fetches twice.
|
|
12
|
+
- The budget test that was supposed to prove the ladder cap had `useProxy:
|
|
13
|
+
false`, so it never reached the tunnel rung. It now asserts the rung after the
|
|
14
|
+
first timeout refuses to start.
|
|
15
|
+
|
|
16
|
+
## 0.13.10
|
|
17
|
+
|
|
18
|
+
### Security
|
|
19
|
+
- The macOS system-proxy probe now spawns `/usr/sbin/scutil` by absolute path
|
|
20
|
+
instead of resolving `scutil` through `PATH`, so a hijacked `PATH` entry cannot
|
|
21
|
+
receive that spawn. This also makes the process list in `SECURITY.md` exact.
|
|
22
|
+
|
|
3
23
|
## 0.13.9
|
|
4
24
|
|
|
5
25
|
### Fixed
|
package/lib/fetch.js
CHANGED
|
@@ -172,10 +172,6 @@ export function createFetchProvider(options = {}, overrides = {}) {
|
|
|
172
172
|
...overrides,
|
|
173
173
|
};
|
|
174
174
|
const timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
175
|
-
const overallMs = options.overallMs ?? DEFAULT_OVERALL_MS;
|
|
176
|
-
const startedAt = Date.now();
|
|
177
|
-
/** What is left of the whole-ladder budget. */
|
|
178
|
-
const remaining = () => Math.max(0, overallMs - (Date.now() - startedAt));
|
|
179
175
|
const maxBytes = options.maxBytes ?? DEFAULT_MAX_BYTES;
|
|
180
176
|
const userAgent = options.userAgent ?? USER_AGENT;
|
|
181
177
|
const apiKey = (options.anysearchApiKey ?? '').trim();
|
|
@@ -275,6 +271,14 @@ export function createFetchProvider(options = {}, overrides = {}) {
|
|
|
275
271
|
if (typeof target !== 'string' || !/^https?:\/\//i.test(target)) {
|
|
276
272
|
throw new SearchError(`not an http(s) URL: ${String(target)}`, 'SEARCH_PARSE', false);
|
|
277
273
|
}
|
|
274
|
+
// The ladder budget belongs to THIS request. Starting it in the factory
|
|
275
|
+
// made it start at plugin mount, so every fetch more than 25 s after a
|
|
276
|
+
// restart failed with "no time left in the fetch budget" before touching
|
|
277
|
+
// the network.
|
|
278
|
+
const overallMs = options.overallMs ?? DEFAULT_OVERALL_MS;
|
|
279
|
+
const startedAt = Date.now();
|
|
280
|
+
/** What is left of the whole-ladder budget for this request. */
|
|
281
|
+
const remaining = () => Math.max(0, overallMs - (Date.now() - startedAt));
|
|
278
282
|
const failures = [];
|
|
279
283
|
/** True once the caller cancelled; a cancellation must not be retried. */
|
|
280
284
|
const cancelled = () => signal !== undefined && signal.aborted;
|
package/lib/proxy.js
CHANGED
|
@@ -197,7 +197,9 @@ export async function proxyFromSystem() {
|
|
|
197
197
|
clearTimeout(timer);
|
|
198
198
|
resolve(value);
|
|
199
199
|
};
|
|
200
|
-
|
|
200
|
+
// Absolute path: a hijacked PATH entry must not be able to receive this
|
|
201
|
+
// spawn. macOS ships scutil at /usr/sbin/scutil.
|
|
202
|
+
const child = spawn('/usr/sbin/scutil', ['--proxy'], { stdio: ['ignore', 'pipe', 'ignore'] });
|
|
201
203
|
// `scutil` answers in milliseconds; a wedged system call must not hold a
|
|
202
204
|
// search open, so the probe is capped and the child is killed on expiry.
|
|
203
205
|
const timer = setTimeout(() => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fffangchenghao/dsh-web-search",
|
|
3
|
-
"version": "0.13.
|
|
3
|
+
"version": "0.13.11",
|
|
4
4
|
"description": "DSH bundle: a key-free web search provider. Leads with the anonymous AnySearch API and falls back to public result pages (DuckDuckGo, Bing, 360), merged by reciprocal-rank fusion with a bilingual region policy, an engine cooldown and a TTL cache.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|