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.

Unmatched requests get logged to the console.

See original GitHub issue

The lib/index.js file is built via webpack and has a console.warn in it in the match function from node-match-path:

/**
 * Matches a given url against a path.
 */
const match = (path, url) => {
    const expression = path instanceof RegExp ? path : pathToRegExp(path);
    const match = expression.exec(url) || false;
    // Matches in strict mode: match string should equal to input (url)
    // Otherwise loose matches will be considered truthy:
    // match('/messages/:id', '/messages/123/users') // true
    const matches = !!match && match[0] === match.input;
    console.warn('nmp', { path, url, match, matches  })
    return {
        matches,
        params: match && matches ? match.groups || null : null,
    };
};

But no version of node-match-path has a console.warn in it. Could we get a rebuild of this and a publish to get rid of that warning? It’s kind of distracting 😅

Thanks!

Issue Analytics

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

github_iconTop GitHub Comments

3reactions
bargarcommented, Sep 15, 2020

For anybody arriving here like me wanting to log requests, you can use this technique:

rest.get('*', (req, res, ctx) => {
  console.log(req.url.href)
  // Notice no `return res()` statement
})

The lack of return means that other handlers can still serve the request after it is logged.

2reactions
kettanaitocommented, Sep 15, 2020

Hey, @bargar! Thanks for posting this for others.

Note that MSW logs out requests that were matched, meaning their responses were mocked. However, you can see those requests and other requests in the “Network” tab of your browser. Sometimes extra logging to the console may not be necessary: just look into the “Network”.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to: let unmatched requests passthrough and reach the ...
I only want fetch-mock to create mock responses for only the registered matchers. If a request doesn't match any matchers then I want...
Read more >
How to see if nock is matching the request or not?
Is there a way one can log information on console regarding nock is matching or not to the requests being made?
Read more >
Verifying whether specific HTTP requests were made | WireMock
Verifying and querying requests relies on the request journal, which is an in-memory log of received requests. This can be disabled for load...
Read more >
Logging & Debugging - MockServer
The simplest way to debug MockServer is to use the UI to view logs, requests and expectations. Retrieving Active Expectations.
Read more >
Troubleshoot alerts on the SEM Console
This section describes how to troubleshoot unmatched data or internal new connector data alerts that may appear in your SEM console.
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

No results found

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