Skip to content

Conversation

@romainmenke
Copy link
Contributor

  • update all dependencies
  • migrate travis CI to github actions
  • migrate test files so that these work with the updated dependencies and in modern node versions

Comment on lines 5 to 34
// DeprecationWarnings are throw higher in the stack since Node 16.
// These can no longer be caught.
test.skip('deprecated constructor', '', (t) => {
t.throws(
() => {
return new Attribute({value: '"foo"', attribute: "data-bar"});
},
{message: "Constructing an Attribute selector with a value without specifying quoteMark is deprecated. Note: The value should be unescaped now."}
);
});

test.skip('deprecated get of raws.unquoted ', '', (t) => {
t.throws(
() => {
let attr = new Attribute({value: 'foo', quoteMark: '"', attribute: "data-bar"});
return attr.raws.unquoted;
},
{message: "attr.raws.unquoted is deprecated. Call attr.value instead."}
);
});

test.skip('deprecated set of raws.unquoted ', '', (t) => {
t.throws(
() => {
let attr = new Attribute({value: 'foo', quoteMark: '"', attribute: "data-bar"});
attr.raws.unquoted = 'fooooo';
},
{message: "Setting attr.raws.unquoted is deprecated and has no effect. attr.value is unescaped by default now."}
);
});
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These always fail in node 16+
The failures are unrelated to updating dependencies.

It seems that the error used to be thrown at the call site but now is throw higher up the stack.

This seems to be related to support for worker threads.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am fine with it curretly (to avoid blocking new release), but I think we should investigate why it happens and how to fix it, because we can't test our deprecated message and it can be a problem...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Happy to look into this further.

This should not be blocking for releases, so maybe best to keep it open until we know more.

@alexander-akait
Copy link
Collaborator

Also I think we can avoid using util-deprecate, it is just small ternary, less deps = less size

@romainmenke
Copy link
Contributor Author

romainmenke commented Nov 26, 2022

I was able to create a minimal repro of what was changed in nodejs for util.deprecate.

import util from 'util';

process.throwDeprecation = true;

const obsoleteFunction = util.deprecate(() => {
    // Do something here.
}, 'obsoleteFunction() is deprecated. Use newShinyFunction() instead.');

try {
    obsoleteFunction();
} catch (err) {
    // node12
    console.log('caught');
}

In node12 the try / catch just works.
In later versions it doesn't.

I was able to work around this by not throwing on deprecations and listening via another method :

function waitForWarning() {
    return new Promise((resolve) => {
        process.once('warning', (err) => {
            resolve(err);
        });
    });
}

@romainmenke
Copy link
Contributor Author

Also I think we can avoid using util-deprecate, it is just small ternary, less deps = less size

Is it possible this was added for when the package is used in browsers?
Removing it might be a breaking change.

@alexander-akait
Copy link
Collaborator

Is it possible this was added for when the package is used in browsers?
Removing it might be a breaking change.

I mean we can copy/paste this code, because it is very simple package

@romainmenke
Copy link
Contributor Author

Is it possible this was added for when the package is used in browsers?
Removing it might be a breaking change.

I mean we can copy/paste this code, because it is very simple package

Maybe best to do this in a follow up PR?
I would have to figure out how to conditionally do require('util') only in nodejs environments and no idea how to do that (yet).

@alexander-akait
Copy link
Collaborator

Maybe best to do this in a follow up PR?

👍

@alexander-akait alexander-akait merged commit fe807ad into postcss:master Nov 27, 2022
@alexander-akait
Copy link
Collaborator

Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants