sanity-io / get-it Goto Github PK
View Code? Open in Web Editor NEWComposable HTTP request library for node and browsers
Home Page: https://get-it-test-next.sanity.build
License: MIT License
Composable HTTP request library for node and browsers
Home Page: https://get-it-test-next.sanity.build
License: MIT License
url
needs to be validated. Currently it does not, and can result in weird errors like protocol mismatch
and similar.
Describe the bug
When using @sanity/client
, that uses get-it under the hood, in a clean React Native Expo app no issues are found when using the standard metro configuration. However when I enable unstable_enablePackageExports
in the Metro config I'm getting the following error in get-it
:
attempted to import the Node standard library module "http". It failed because the native React runtime does not include the Node standard library.
When that setting is enabled get-it
somehow forgets to specify the correct runtime?
To Reproduce
Steps to reproduce the behavior:
@sanity/client
request.unstable_enablePackageExports
to true
Which versions of Sanity are you using?
Latest
What operating system are you using?
React Native on the latest version of iOS.
Which versions of Node.js / npm are you running?
10.5.0
v20.12.0
This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.
Using a curated preset maintained by
These branches will be created by Renovate only once you click their checkbox below.
These are blocked by an existing closed PR and will not be recreated unless you click a checkbox below.
.github/workflows/browserslist.yml
actions/checkout v4
actions/setup-node v4
actions/create-github-app-token v1
peter-evans/create-pull-request v6@6d6857d36972b65feb161a90e484f2984215f83e
.github/workflows/ci.yml
actions/checkout v4
actions/setup-node v4
actions/checkout v4
actions/setup-node v4
actions/checkout v4
actions/setup-node v4
actions/checkout v4
actions/setup-node v4
denoland/setup-deno v1
actions/checkout v4
actions/setup-node v4
actions/checkout v4
actions/setup-node v4
actions/create-github-app-token v1
actions/checkout v4
actions/setup-node v4
.github/workflows/lock.yml
dessant/lock-threads v5@1bf7ec25051fe7c00bdd17e6a7cf3d7bfb7dc771
.github/workflows/prettier.yml
actions/checkout v4
actions/setup-node v4
actions/cache v4
actions/create-github-app-token v1
peter-evans/create-pull-request v6@6d6857d36972b65feb161a90e484f2984215f83e
package.json
decompress-response ^7.0.0
follow-redirects ^1.15.6
is-retry-allowed ^2.2.0
progress-stream ^2.0.0
tunnel-agent ^0.6.0
@edge-runtime/vm ^3.2.0
@sanity/pkg-utils ^6.10.0
@sanity/semantic-release-preset ^5.0.0
@types/bun ^1.1.4
@types/follow-redirects ^1.14.4
@types/progress-stream ^2.0.5
@types/zen-observable ^0.8.7
@typescript-eslint/eslint-plugin ^7.13.1
@typescript-eslint/parser ^7.13.1
@vitest/coverage-v8 ^1.6.0
eslint ^8.57.0
eslint-config-prettier ^9.1.0
eslint-plugin-prettier ^5.1.3
eslint-plugin-simple-import-sort ^12.1.0
faucet ^0.0.4
happy-dom 12.10.3
ls-engines ^0.9.2
node-fetch ^2.6.7
parse-headers 2.0.5
prettier ^3.3.2
prettier-plugin-packagejson ^2.5.0
semantic-release ^24.0.0
typescript 5.4.5
vite 5.3.1
vitest ^1.6.0
vitest-github-actions-reporter ^0.11.1
zen-observable ^0.10.0
node >=14.0.0
The following fails with Uncaught Error: "/some/endpoint" is not a valid URL
:
const request = getIt([jsonResponse()])
request('/some/endpoint')
Is there any way configure get-it to allow both relative urls and absolute urls?
The Node.js compatibility mode in Deno is removed. The CI tests need to be rewritten to use the new npm:
protocol.
Just had deployments starting to crash on vercel after get-it versions for sanity packages were bumped to 8.10 from 8.0.11
I confirmed the break to be in this version by overriding just get-it back to 8.0.11.
Here's the stack trace from the function failure:
TypeError: Right-hand side of 'instanceof' is not an object
at (../../node_modules/.pnpm/[email protected]/node_modules/get-it/dist/index.browser.js:185:0)
at (../../node_modules/.pnpm/[email protected]/node_modules/get-it/dist/index.browser.js:283:0)
at (../../node_modules/.pnpm/[email protected]/node_modules/get-it/dist/index.browser.js:67:0)
at (../../node_modules/.pnpm/[email protected]/node_modules/get-it/dist/index.browser.js:33:0)
at (../../node_modules/.pnpm/[email protected]/node_modules/get-it/dist/middleware.browser.js:255:0)
at (../../node_modules/.pnpm/[email protected]/node_modules/rxjs/dist/cjs/internal/Observable.js:41:0)
at (../../node_modules/.pnpm/[email protected]/node_modules/rxjs/dist/cjs/internal/Observable.js:35:0)
at (../../node_modules/.pnpm/[email protected]/node_modules/rxjs/dist/cjs/internal/util/errorContext.js:22:0)
at (../../node_modules/.pnpm/[email protected]/node_modules/rxjs/dist/cjs/internal/Observable.js:26:0)
at (../../node_modules/.pnpm/@[email protected]/node_modules/@sanity/client/dist/index.browser.js:812:0)
Remove the workspaces
property from package.json
:
Line 86 in 5b817f2
Now, it causes the following warning:
warning Workspaces can only be enabled in private projects.
Hey there!
I belong to an open source security research community, and a member (@ranjit-git) has found an issue, but doesnβt know the best way to disclose it.
If not a hassle, might you kindly add a SECURITY.md
file with an email, or another contact method? GitHub recommends this best practice to ensure security issues are responsibly disclosed, and it would serve as a simple instruction for security researchers in the future.
Thank you for your consideration, and I look forward to hearing from you!
(cc @huntr-helper)
The module is required by @sanity/client
Using npm 6.4.1 and Brunch 2.10.17.
Npm compiles the module creating two folders 'lib' and 'lib-node'. However, main entry file index.js points just to './lib-node'
module.exports = require('./lib-node')
This causes module to fail in browser context, where only '/lib' is bundled. However, everything works just fine when manually changed to:
module.exports = require('./lib')
Is this a problem with module or more probably with bundler?
Now that TC39 has landed on an API for aborting ongoing activities, it would be nice to make the promise middleware switch to this pattern. Not all browsers currently support this, so it would probably need a "polyfill".
The debug middleware tries to use the error in onError
, but if an earlier handler has "handled" the error, it'll be null and thus fail.
With the middleware architecture in place, it shouldn't be too difficult to add support for mocking responses. That would be a nice addition that would ease testing in a lot of scenarios, in a way that would work in both browsers and on the server.
Sometimes, all you care about is the response body. For instance, if you are using the httpErrors
-middleware, errors are handled "for you", and thus you don't need access to the status code. So it would be great to have a... resolveWithBody
-option (name suggestions are welcome) that only resolves the promise with the response body. This reads much nicer with async/await and friends:
const projects = await request({ url: '/v1/projects' })
// vs
const projects = (await request({ url: '/v1/projects' })).body
It'd be nice to have a middleware that could limit the number of response size.
If a content-length is received, that could be used, otherwise just count bytes from the stream.
Don't think we could get this working with the XHR adapter, but should work in Node, and possibly a future fetch adapter (now that streams are implemented/on the way).
There is a bug in the implementation of the error handling.
When an error is encountered (for instance, in the case of a network error or a timeout), the way we wanted to handle retries is to "catch" the error and signal to the requester that it has been handled by simply not returning the error.
The issue is that if no error is returned, the response channel is published to instead.
We need to figure out a way for middleware to be able to say "I've got this, but the request isn't done yet". There aren't currently any other middlewares that utilitize the error capturing, so perhaps we could just leave it up to the middleware to publish a message on the response channel if it wants to somehow trigger the response. Need to think on this some more.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. πππ
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google β€οΈ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.