Edge throws “TypeMismatchError” when setting custom header for fetch request with formated date

Duplicate Issue #11358518 • See Issue #11907540


Michael H.
Mar 22, 2017
This issue is public.
Found in
  • Microsoft Edge
See progress on Bug #11907540
Reported by 3 people

Sign in to watch or report this issue.

Steps to reproduce

Whilst this is working in IE & Chrome, Edge throws TypeMismatchError when setting a custom header to a fetch request using request.headers.set('x-date', dateStr);.

Here are my findings so far:

This is working:

request.headers.set('x-date', '1/9/2014 8:51:15 AM');

This is working:

const dateStr = '1/9/2014 8:51:15 AM';
request.headers.set('x-date', dateStr);

This is working:

const dateStr = Moment().format('l LTS');
request.headers.set('x-date', dateStr);

This is not working:

const dateStr = new Date().toLocaleString('en-US').replace(',', '');
request.headers.set('x-date', dateStr);

I don’t see any differences when logging Moment().format('l LTS') & new Date().toLocaleString('en-US').replace(',', '') to the console…


Comments and activity

  • Microsoft Edge Team

    Changed Assigned To to “James M.”

    Changed Status to “Not reproducible”

  • Hello,

    Thank you for providing this information about the issue. After thorough testing, we are unable to reproduce this problem in Edge with the information at hand. Please update this case when you can provide more details, such as a sample code we may review.

    Best Wishes,
    The MS Edge Team

  • Changed Status from “Not reproducible”

  • I’ve created a sample app which can be reached here.

    If you click Fetch it with Use vanilla date unchecked, the x-date header value is created using moment js and everything is working as expected.

    With Use vanilla date checked, the x-date header value is generated using vanilla JS (new Date().toLocaleString...) and Edge is throwing the TypeMismatchError.

    Also see the screenshot I’ve attached to the issue itself.

    Both options are working just fine in Chrome 57 & Firefox 52.

  • Microsoft Edge Team

    Changed Assigned To to “James M.”

    Changed Assigned To to “Venkat K.”

    Changed Assigned To from “Venkat K.” to “Mohamed K.”

    Changed Status to “Confirmed”

  • Any status on this? I ran into this today. It was causing Edge to return a “400 Bad Request” on an ajax post. If I look at the Headers of the request using the Network tab in dev tools, the date value in the header is all "scrambled":

    �9�/�27�/�2017� �11�:�08�:�01� �PM

    The value I set the header to was:
    ‎new Date().toLocaleString(‘en-US’).replace(',’, ‘’)


  • Microsoft Edge Team

    Changed Status from “Confirmed” to “Duplicate”

  • This bug has marked as duplicate. Please follow the parent issue to get new updates.

You need to sign in to your Microsoft account to add a comment.

Sign in