13.0.3 • Published 5 years ago

vizsla v13.0.3

Weekly downloads
12
License
MIT
Repository
github
Last release
5 years ago

Build Status Coverage Status

An error-first callback friendly user agent.

This exists because I always have to:

  • Convert buffers to strings using the correct encoding.
  • Parse JSON bodies.
  • Resolve relative URLs.
  • Fuss with formatting bearer token headers.
  • Catch JSON parse errors.
  • Not parse a JSON body if there is an error (because it could be a proxy.)
  • Not trust content type unless everything is hunky dory, otherwise don't bother with the body.
  • Cancel HTTP requests before and after the response has started streaming.
  • Drain the HTTP response if you cancel or for other reasons do not consume the body.

HTTP is not a simple fetch. Even if I'm good about HTTP mime-types, there are always proxies and whatnot that I use.

HTTP clients are different from HTTP servers. They have to deal with gateways and caching doing rude thing coming back that they don't do going forward. They have to implement redirections and authentication. The have to implement retries.

Vizsla is supposed to help you build a client appropriate for your application, but retries and redirects ought to be a part of your application.

As for gateways (a plugin mechanism) there are two things that you do with them, negotiate and parse. That is about it. Either you are intercepting an response response and retrying, like a redirect, or you are running the response through a pipeline.

If instead of an array of gateways we have an array of negotation gateways and parsing gateways. This accommodates the common case of setting redirects and authentication negotiation at the outset while swapping out different parse responses for different requests.

Now trying to sort out whether to shoehorn all errors into response reports, which would sacrifice stack traces, or to make them all Errors which is difficult because you don't really consider a 404 to be an Error. A connection timeout doesn't have a meaningful stack trace. Hmm… That kind of answers it, doesn't it?

If there is a stack you can put it in stack, which will get it into the logging one way or another in case you do have a bonafide exception, but who gets those anymore? You don't get out of memory errors ever, you just get OOMKilled.

Ah, but still. Even if you do have an OOM error, what good is the stack trace? Maybe we go ahead and check the result codes and see what sort of errors are actually raised. Maybe the lack of a code causes it to get written to standard error so that we can debug it. Maybe we log the error with the trace level and we can turn that one to see the stack trace.

But, I don't imagine that ordinary usage would benefit from a stack trace because we're not expecting stack trace based errors.

Errors ought to be messages, we cordon it off into a JSON structure that can be stuffed into an exception and thrown if that's what you'd prefer. There is a status code and status message, but not always a body. There is a stage which can be 'negotiate', 'transport' or 'parse'.

14.0.6

5 years ago

14.0.5

5 years ago

14.0.4

5 years ago

14.0.3

5 years ago

14.0.2

5 years ago

14.0.1

5 years ago

14.0.0

5 years ago

13.0.3

5 years ago

13.0.2

5 years ago

13.0.1

5 years ago

13.0.0

5 years ago

12.17.0

5 years ago

12.16.0

5 years ago

12.15.0

6 years ago

12.14.0

6 years ago

12.13.1

6 years ago

12.13.0

6 years ago

12.12.0

6 years ago

12.11.0

6 years ago

12.10.2

6 years ago

12.10.1

6 years ago

12.10.0

6 years ago

12.9.5

6 years ago

12.9.4

6 years ago

12.9.3

6 years ago

12.9.2

6 years ago

12.9.1

6 years ago

12.8.3

6 years ago

12.9.0

6 years ago

12.8.2

6 years ago

12.8.1

6 years ago

12.8.0

6 years ago

12.7.1

6 years ago

12.7.0

6 years ago

12.6.0

6 years ago

12.5.0

6 years ago

12.4.0

6 years ago

12.3.0

6 years ago

12.2.3

6 years ago

12.2.2

6 years ago

12.2.1

6 years ago

12.2.0

6 years ago

12.1.0

6 years ago

12.0.2

6 years ago

12.0.1

6 years ago

12.0.0

6 years ago

11.0.1

6 years ago

11.0.0

6 years ago

10.7.6

6 years ago

10.7.5

6 years ago

10.7.4

6 years ago

10.7.3

6 years ago

10.7.2

6 years ago

10.7.1

6 years ago

10.7.0

6 years ago

10.6.0

6 years ago

10.5.1

6 years ago

10.5.0

6 years ago

10.4.0

6 years ago

10.3.1

6 years ago

10.3.0

6 years ago

10.2.1

6 years ago

10.2.0

6 years ago

10.1.0

6 years ago

10.0.0

7 years ago

9.0.3

7 years ago

9.0.2

7 years ago

9.0.1

7 years ago

9.0.0

7 years ago

8.0.0

7 years ago

7.0.2

7 years ago

7.0.1

7 years ago

7.0.0

7 years ago

6.0.0

7 years ago

5.2.1

7 years ago

5.2.0

7 years ago

5.1.0

7 years ago

5.0.0

7 years ago

4.0.3

7 years ago

4.0.2

7 years ago

4.0.1

7 years ago

4.0.0

7 years ago

3.6.2

7 years ago

3.6.1

7 years ago

3.6.0

7 years ago

3.4.0

7 years ago

3.2.0

7 years ago

3.1.0

7 years ago

3.0.0

7 years ago

2.0.4

7 years ago

2.0.3

8 years ago

2.0.2

8 years ago

2.0.1

8 years ago

2.0.0

8 years ago

1.6.3

8 years ago

1.6.2

8 years ago

1.6.1

8 years ago

1.6.0

8 years ago

1.5.5

8 years ago

1.5.4

8 years ago

1.5.3

8 years ago

1.5.2

8 years ago

1.5.1

8 years ago

1.5.0

8 years ago

1.4.0

8 years ago

1.3.6

8 years ago

1.3.5

8 years ago

1.3.4

8 years ago

1.3.3

8 years ago

1.3.2

8 years ago

1.3.1

8 years ago

1.3.0

8 years ago

1.2.4

8 years ago

1.2.3

8 years ago

1.2.2

8 years ago

1.2.1

8 years ago

1.2.0

8 years ago

1.1.1

8 years ago

1.1.0

8 years ago

1.0.0

8 years ago

0.0.10

8 years ago

0.0.9

8 years ago

0.0.8

8 years ago

0.0.7

9 years ago

0.0.6

9 years ago

0.0.5

9 years ago

0.0.4

9 years ago

0.0.3

9 years ago

0.0.2

9 years ago

0.0.1

9 years ago

0.0.0

9 years ago