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.

Custom properties for config

See original GitHub issue

So, if I understand it right, in 0.19.0 you’ve added mergeConfig And this function filter config and remove custom properties from it. It broke my solution for cancellation:

How it works:

const requestManager = new RequestManager();
const instance = axios.create();
requestManager.patchAxiosInstance(instance);

const search = q =>
  instance.get('/search', {
    cancelable: true, // this is no longer possible in 0.19.0
    params: { q },
  });

Screenshot 2019-06-05 at 16 30 01

The solution:

class RequestManager {
  constructor() {
    this.pendingRequests = new Map();
  }

  patchAxiosInstance(instance) {
    instance.interceptors.request.use(config => {
      if (!config.cancelable) return config; // this is no longer possible in 0.19.0

      const source = axios.CancelToken.source();
      const requestId = `${config.method}_${config.url}`;
      const cancelToken = source.token;
      this.addRequest(requestId, source.cancel);
      return { ...config, cancelToken, requestId };
    });

    instance.interceptors.response.use(response => {
      const { requestId } = response.config; // this is no longer possible in 0.19.0
      if (requestId) {
        this.removeRequest(requestId);
      }
      return response;
    });
  }

  addRequest(requestId, cancelFn) {
    this.cancelRequest(requestId);
    this.pendingRequests.set(requestId, cancelFn);
  }

  removeRequest(requestId) {
    this.pendingRequests.delete(requestId);
  }

  cancelRequest(requestId) {
    if (this.pendingRequests.has(requestId)) {
      const cancelFn = this.pendingRequests.get(requestId);
      cancelFn();
      this.removeRequest(requestId);
    }
  }
}

So, is it possible to relax filter in mergeConfig for custom properties? Because sometimes it is needed and very helpful in interceptors or somewhere else.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:42
  • Comments:14 (1 by maintainers)

github_iconTop GitHub Comments

19reactions
shinycommented, Oct 23, 2019

it refusing me too, this bug still exists since axios stays at version 0.19.0.

17reactions
crobinson42commented, Oct 20, 2019

This is still very much a bug/issue that should remain open, I agree with @someden - until this is released to npm, it is not useful for any consumers of the package to have this ticket closed.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Custom Properties in Configurations - SolidWorks Web Help
where property is the name of a custom property. You can use one of the custom properties listed in the Summary Information dialog...
Read more >
Custom Configuration Properties Provider
You can use the Mule SDK and Mule API to create a custom configuration properties provider that enables an app to discover configuration...
Read more >
Guide to @ConfigurationProperties in Spring Boot - Baeldung
Spring Boot has many useful features including externalized configuration and easy access to properties defined in properties files.
Read more >
Custom properties for devices - Configuration Manager
Set properties via UI · In the Configuration Manager console, go to the Assets and Compliance workspace, and select the Devices node. ·...
Read more >
Configuring custom properties to secure web services - IBM
Configuring custom properties to secure web services. You can configure name-value pairs of data, where the name is a property key and the...
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

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