question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Proxy settings not applied to all outgoing requests

See original GitHub issue

Describe the bug

While using spectral on a corporate network, our lints are taking a long time (hitting a network timeout) because not all outgoing connections are honouring the proxy settings.

After initiating a lint, spectral seemed to hang and we tracked this to an outgoing connection to http://json-schema.org on startup:

NET 338: createConnection [
  {
    protocol: 'http:',
    slashes: true,
    auth: null,
    host: 'json-schema.org',
    port: 80,
    hostname: 'json-schema.org',
    hash: null,
    search: null,
    query: null,
    pathname: '/draft-04/schema',
    path: null,
    href: 'http://json-schema.org/draft-04/schema',
    method: 'GET',
    headers: [Object: null prototype] {
      Accept: [Array],
      'User-Agent': [Array],
      'Accept-Encoding': [Array],
      Connection: [Array]
    },
    agent: undefined,
    servername: 'json-schema.org',
    _agentKey: 'json-schema.org:80:',
    encoding: null
  },
  [Function: oncreate],
  [Symbol(normalizedArgs)]: true
]

...

TIMER 304: process timer lists 136415
TIMER 304: timeout callback 1000
TIMER 304: 1000 list wait because diff is 0
TIMER 304: process timer lists 137416
TIMER 304: timeout callback 1000
TIMER 304: 1000 list wait because diff is 0
TIMER 304: process timer lists 138417
TIMER 304: timeout callback 1000
TIMER 304: 1000 list wait because diff is 0
TIMER 304: process timer lists 139418
TIMER 304: timeout callback 1000
TIMER 304: 1000 list wait because diff is 0
TIMER 304: process timer lists 140419
TIMER 304: timeout callback 1000

...

Looks like this is triggered from one of the libraries (ajv?), and it is not respecting the proxy settings. The net effect is that on startup spectral will hang for a big while until the timeout hits and then the lint continues.

On top of this, the standard environment variables HTTP(S)_PROXY are not used to configure the proxy settings, the CLI will only recognize PROXY. This is documented in https://meta.stoplight.io/docs/spectral/docs/guides/2-cli.md#proxying, but it is non-standard behaviour.

Environment

  • Spectral: 5.5.0 via CLI
  • OS: Observed both on macOS 10.15.6 with node 12.10.0 and gitlab-ci running latest image node:erbium

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:3
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

4reactions
P0lipcommented, Feb 25, 2021

Yup, I can confirm the issue. I already pushed the fix onto fix/ruleset-proxy however prior to opening a PR, I’ll add a few tests making sure everything’s in tact.

3reactions
samcrutt9900commented, Feb 19, 2021

I am experiencing the same issue behind a corporate proxy. Interestingly I checked the code out and attempted to build it. I get a similar issue during the build process where it appears to be attempting to resolve http://json-schema.org/draft-04/schema. The error is:

./scripts/generate-assets.ts
(node:4209) UnhandledPromiseRejectionWarning: ResolverError: Error downloading http://json-schema.org/draft-04/schema 
connect ETIMEDOUT *******:80
    at /home//spectral/node_modules/@apidevtools/json-schema-ref-parser/lib/resolvers/http.js:127:16
    at processTicksAndRejections (internal/process/task_queues.js:97:5)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Configure device proxy and Internet connection settings
Configure the proxy server manually using netsh command​​ Use netsh to configure a system-wide static proxy. This will affect all applications ...
Read more >
Global proxy settings for all Windows applications in Windows ...
The short answer is: you can't. There is no "global" proxy setting, because proxies are used by individual applications (like Internet ...
Read more >
Configuring outgoing HTTP requests from Java process via ...
Our Tomcat application can be configured to connect to a website to gather information, but the app cannot be configured with a proxy...
Read more >
How to Configure Outbound HTTP and HTTPS Proxy for your ...
If the http.nonProxyHosts property is not configured, all web requests will be routed through the proxy. This could break Application Links. For ...
Read more >
Set Apache outgoing requests to go through a proxy
Apache does not make requests on its own. You have an application that is running on Apache, and that application needs to request...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found