Giter VIP home page Giter VIP logo

get-it's Issues

Support for package exports in React Native breaks get-it

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:

  1. Create a new clean React Native app using Expo.
  2. Implement a @sanity/client request.
  3. Set unstable_enablePackageExports to true
  4. See error

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

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.


Using a curated preset maintained by


Sanity: The Composable Content Cloud

Pending Approval

These branches will be created by Renovate only once you click their checkbox below.

  • chore(deps): update peter-evans/create-pull-request digest to c5a7806
  • chore(deps): update dependency @types/bun to ^1.1.5
  • chore(deps): lock file maintenance
  • πŸ” Create all pending approval PRs at once πŸ”

Ignored or Blocked

These are blocked by an existing closed PR and will not be recreated unless you click a checkbox below.

Detected dependencies

github-actions
.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
npm
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

  • Check this box to trigger a request for Renovate to run again on this repository

Can't use with relative urls in a browser context

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?

8.1.0 crashing on vercel

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)

Security concern

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)

Cannot find module 'get-it/lib-node'

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?

Add support for mocking responses

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.

Promise: Add option to resolve only body

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

Ability to set max response size

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).

Retry triggers response callback

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.