Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Polyfill for URL is incomplete and causes crash with apollo-server #22594

Closed
3 tasks done
matthargett opened this issue Dec 11, 2018 · 2 comments
Closed
3 tasks done

Polyfill for URL is incomplete and causes crash with apollo-server #22594

matthargett opened this issue Dec 11, 2018 · 2 comments
Labels
Partner Platform: Linux Building on Linux. Resolution: Locked This issue was locked by the bot. Type: Discussion Long running discussion.

Comments

@matthargett
Copy link
Contributor

matthargett commented Dec 11, 2018

Environment

  React Native Environment Info:
    System:
      OS: Linux 4.4 Ubuntu 18.04.1 LTS (Bionic Beaver)
      CPU: x64 Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz
      Memory: 6.07 GB / 15.93 GB
      Shell: 4.4.19 - /bin/bash
    Binaries:
      Node: 10.12.0 - ~/.nvs/node/10.12.0/x64/bin/node
      Yarn: 1.10.1 - ~/.nvs/node/10.12.0/x64/bin/yarn
      npm: 6.4.1 - ~/.nvs/node/10.12.0/x64/bin/npm
    npmPackages:
      react: 16.5.0 => 16.5.0
      react-native: 0.57.1 => 0.57.1
    npmGlobalPackages:
      react-native-cli: 2.0.1

Description

To add non-URL (local) Blob support, a simple polyfill for one static method on the URL object was added here:


(note that the ctor throws)

This triggers an exception Apollo Server tries to do a new URL() here:
https://github.com/apollographql/apollo-server/blob/458bc71eadde52483ccaef209df3eb1f1bcb4424/packages/apollo-datasource-rest/src/RESTDataSource.ts#L79

It then uses the SearchParams collection on the URL to add parameters:
https://github.com/apollographql/apollo-server/blob/458bc71eadde52483ccaef209df3eb1f1bcb4424/packages/apollo-datasource-rest/src/RESTDataSource.ts#L218

And then constructs a string, implicitly calling the url.toString() method:
https://github.com/apollographql/apollo-server/blob/458bc71eadde52483ccaef209df3eb1f1bcb4424/packages/apollo-datasource-rest/src/RESTDataSource.ts#L233

Reproducible Demo


import { RESTDataSource } from 'apollo-datasource-rest';

export default class SearchDataSource extends RESTDataSource {
  constructor() {
    super();
    this.baseURL = `https://foo.com/`;
  }

  async search(searchString, options) {
    return this.get('universalSearch', {
      searchTerm: this.searchString,
    });
  }
}

const sds = new SearchDataSource();

@matthargett matthargett added the Type: Discussion Long running discussion. label Dec 11, 2018
@matthargett matthargett changed the title Polyfill for URL incomplete and incompatible with URL object use in apollo-server Polyfill for URL incomplete causes crash with apollo-server Dec 11, 2018
@matthargett matthargett changed the title Polyfill for URL incomplete causes crash with apollo-server Polyfill for URL is incomplete and causes crash with apollo-server Dec 12, 2018
@koenpunt
Copy link
Contributor

Maybe a stupid question, but why are you using Apollo server on a client?

@matthargett
Copy link
Contributor Author

Closed with #22901

@facebook facebook locked as resolved and limited conversation to collaborators Feb 28, 2020
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Feb 28, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Partner Platform: Linux Building on Linux. Resolution: Locked This issue was locked by the bot. Type: Discussion Long running discussion.
Projects
None yet
Development

No branches or pull requests

4 participants