The 'message board' project boilerplate 'fcctesting.js' file uses an instance of deprecated language, which stops users from being able to pass the test


When trying to pass the FCC tests, I kept getting this error message:

(node:2677) [DEP0066] DeprecationWarning: OutgoingMessage.prototype._headers is deprecated

So I checked all files in the boilerplate repl to see where ‘_headers’ was written (apparently ‘_headers’ cannot be used any more in Node.js, giving rise to this error)

I noticed ‘_headers’ was written in the file ‘fcctesting.js’ on line 75, as follows:

  app.get('/_api/app-info', function(req, res) {
    var hs = Object.keys(res._headers)
      .filter(h => !h.match(/^access-control-\w+/));
    var hObj = {};
    hs.forEach(h => {hObj[h] = res._headers[h]});
    delete res._headers['strict-transport-security'];
    res.json({headers: hObj});

Node.js documentation says the following concerning this matter:

DEP0066: OutgoingMessage.prototype._headers, OutgoingMessage.prototype._headerNames#
Type: Runtime

The http module OutgoingMessage.prototype._headers and OutgoingMessage.prototype._headerNames properties are deprecated. Use one of the public methods (e.g. OutgoingMessage.prototype.getHeader(), OutgoingMessage.prototype.getHeaders(), OutgoingMessage.prototype.getHeaderNames(), OutgoingMessage.prototype.getRawHeaderNames(), OutgoingMessage.prototype.hasHeader(), OutgoingMessage.prototype.removeHeader(), OutgoingMessage.prototype.setHeader()) for working with outgoing headers.

The OutgoingMessage.prototype._headers and OutgoingMessage.prototype._headerNames properties were never documented as officially supported properties.

Changing ‘._headers’ to ’ .getHeaders()’ makes the ‘deprecated’ error disappear

Thanks for your time


Your project link(s)

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36

Challenge: Anonymous Message Board

Link to the challenge:

Deprecation warnings shouldn’t affect your code. They are there to warn about the possible removal or breaking change of a feature in future versions. After the removal or breaking change, it will no longer be a warning but a code-breaking error.

I will say using private undocumented parts of an API is never a good idea and the tests shouldn’t do so unless there is no other way (which there usually is).


Looking at the code I’m not even sure why it’s needed. There seems to be no reason to remove the headers it is before sending back the new headers object.

This passes the tests as well.

app.get('/_api/app-info', function(req, res) {
  res.json({ headers: res.getHeaders()});

Edit: BTW, a lot of the tests are not even implemented yet.

1 Like

My best guess would be that it was necessary for Hyperdev/Glitch back in the day.

1 Like

So I guess it would need to be tested on Glitch as well before (if) the code is updated.

@Sky020 I was going to open an issue and ask about the code, should I still do so?

Oh and happy birthday :cake:

Issues: Anonymous Message Board headers test · Issue #44174 · freeCodeCamp/freeCodeCamp · GitHub

1 Like

Yes, that issue makes sense. I will comment more on the issue, but I think it is time we made use of updated tooling to improve and simplify the tests.

:grin: Thank you.


This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.