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

Re(#829) WHATWG url path gets removed from request #847

Closed
daniel-edwards-iress opened this issue Feb 4, 2020 · 0 comments · Fixed by #848
Closed

Re(#829) WHATWG url path gets removed from request #847

daniel-edwards-iress opened this issue Feb 4, 2020 · 0 comments · Fixed by #848
Labels
bug Something isn't working community integrations

Comments

@daniel-edwards-iress
Copy link

daniel-edwards-iress commented Feb 4, 2020

Describe the bug
#829 not fully fixed
When making a request using a WHATWG URL object (node URL) dd-trace clears the request path from the URL.

The latest Got converts urls before making the request.

Simple Example

{
  "name": "test",
  "version": "1.0.0",
  "main": "index.js",
  "license": "MIT",
  "dependencies": {
    "dd-trace": "^0.17.0"
  }
}
const assert = require('assert');
require('dd-trace').default.init({
  service: 'test',
  runtimeMetrics: true,
  env: 'test',
  logger: {
    debug: console.log,
    error: console.error,
  },
  analytics: true,
  logInjection: false,
});
const url = 'https://postman-echo.com/get?test=123';

const incorrect = new Promise((resolve, reject) => {
  let response = '';

  require('https')
    .request(new URL(url), res => {
      res.on('data', d => (response += d));
      res.on('error', reject);
      res.on('end', () => resolve(response));
    })
    .end();
});

const correct = new Promise((resolve, reject) => {
  let response = '';

  require('https')
    .request(url, res => {
      res.on('data', d => (response += d));
      res.on('error', reject);
      res.on('end', () => resolve(response));
    })
    .end();
});

Promise.allSettled([correct, incorrect]).then(results => {
  assert(results.every(v => v.status === 'fulfilled'));
  assert(results[0] === results[1]);
});

Environment

  • docker node:12
  • node 12.14.1
  • dd-trace 0.17.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working community integrations
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants