Skip to content

It is wrong to save empty available versions as cache when connection failed #16

@zhangkaizhao

Description

@zhangkaizhao

connection failed:

% curl -v https://nodejs.org/dist/index.json
* Host nodejs.org:443 was resolved.
* IPv6: 2606:4700:10::6814:162e, 2606:4700:10::6814:172e
* IPv4: 104.20.23.46, 104.20.22.46
*   Trying 104.20.23.46:443...
*   Trying [2606:4700:10::6814:162e]:443...
* Immediate connect fail for 2606:4700:10::6814:162e: No route to host
*   Trying [2606:4700:10::6814:172e]:443...
* Immediate connect fail for 2606:4700:10::6814:172e: No route to host
* connect to 104.20.23.46 port 443 from 192.168.31.38 port 58385 failed: Operation timed out
*   Trying 104.20.22.46:443...
* connect to 104.20.22.46 port 443 from 192.168.31.38 port 58395 failed: Operation timed out
* Failed to connect to nodejs.org port 443 after 150188 ms: Couldn't connect to server
* Closing connection
curl: (28) Failed to connect to nodejs.org port 443 after 150188 ms: Couldn't connect to server

but vfox with nodejs plugin saves empty available versions as cache:

% rm -f .version-fox/plugin/nodejs/available.cache
% vfox --debug search nodejs
CallFunction: Available
Available hook cache duration: 12h
Available hook cache key: empty, hit: false 
# -> NOTE: here wait for a long time to timeout
no available version
% hexyl .version-fox/plugin/nodejs/available.cache 
┌────────┬─────────────────────────┬─────────────────────────┬────────┬────────┐
│00000000│ 0f ff 81 04 01 02 ff 82 ┊ 00 01 0c 01 ff 80 00 00 │•×ו••××┊⋄•_•××⋄⋄│
│00000010│ 1e 7f 03 01 02 ff 80 00 ┊ 01 02 01 03 56 61 6c 01 │•••••××⋄┊••••Val•│
│00000020│ 0a 00 01 06 45 78 70 69 ┊ 72 65 01 04 00 00 00 19 │_⋄••Expi┊re••⋄⋄⋄•│
│00000030│ ff 82 00 01 05 65 6d 70 ┊ 74 79 01 02 5b 5d 01 f8 │××⋄••emp┊ty••[]•×│
│00000040│ 2f e6 61 57 93 68 6f c0 ┊ 00                      │/×aW×ho×┊⋄       │
└────────┴─────────────────────────┴─────────────────────────┴────────┴────────┘
% vfox --debug search nodejs                      
CallFunction: Available
Available hook cache duration: 12h
Available hook cache key: empty, hit: true 
# -> NOTE: here now use available cache immediately
no available version

nodejs plugin info:

% vfox info nodejs
Plugin Info:
Name     -> nodejs
Version  -> 0.3.0
Homepage -> https://github.com/version-fox/vfox-nodejs
Desc     ->
Node.js runtime environment.
Legacy Files -> [.node-version .nvmrc]

expected:
Just show error output and no need to save anything as cache when connection failed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions