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

[api-minor] Update the minimum supported Node.js version to 20, and only support the Fetch API for "remote" PDF documents in Node.js #18959

Merged
merged 4 commits into from
Nov 4, 2024

Conversation

Snuffleupagus
Copy link
Collaborator

@Snuffleupagus Snuffleupagus commented Oct 26, 2024

  • [api-minor] Update the minimum supported Node.js version to 20

    This patch updates the minimum supported environments as follows:

    Furthermore, note also that Node.js 18 will fairly soon reach EOL.

  • [api-minor] Load Node.js packages/polyfills with process.getBuiltinModule

    This allows synchronous loading of Node.js modules and (indirectly) packages, thus simplifying the code a fair bit.

  • [api-minor] Only support the Fetch API for "remote" PDF documents in Node.js environments

    The Fetch API has been supported since Node.js version 18, see https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API#browser_compatibility

  • Remove the BaseFullReader and BaseRangeReader classes in the src/display/node_stream.js file

    After the previous patch these base-classes are only extended once each and they can thus be combined with the final classes.


Edit: I intend to submit this for review after the upcoming release.

@timvandermeij
Copy link
Contributor

To unblock this patch we temporarily disable the now failing gulp typestest in GitHub Actions

Do you have e.g. a traceback of what's failing? I can have a look to see if we can perhaps easily fix that.

@Snuffleupagus

This comment was marked as resolved.

@Snuffleupagus

This comment was marked as resolved.

timvandermeij added a commit to timvandermeij/pdf.js that referenced this pull request Nov 3, 2024
The types tests run in Node.js and therefore use Node types for e.g.
builtins. However, we didn't explicitly indicate this in
`tsconfig.json` (see [1] for more information and [2] for the PR where
we found this). Moreover, we didn't explicitly install the most recent
version of `@types/node` which implicitly made us fall back to version
14.14.45 (because that was installed as a dependency of other modules)
whereas much newer versions are available and we need those after
changes in Node.js (see [3] for more information and [4] for the PR
where we found this).

This commit fixes both issues by explicitly installing and using the
most recent Node.js types, which should also avoid future issues with
the types tests.

[1] TypeStrong/ts-node#1012
[2] mozilla#18237
[3] https://stackoverflow.com/questions/78790943/in-typescript-5-6-buffer-is-not-assignable-to-arraybufferview-or-uint8arr
[4] mozilla#18959
Copy link
Contributor

@timvandermeij timvandermeij left a comment

Choose a reason for hiding this comment

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

Looks good to me, with the two comments addressed and #18996 resolved. Thanks!

.github/workflows/ci.yml Show resolved Hide resolved
test/unit/node_stream_spec.js Outdated Show resolved Hide resolved
This patch updates the minimum supported environments as follows:
 - Node.js 20, which was released on 2023-04-18 and has now entered the "Maintenance"-phase; see https://github.com/nodejs/release#release-schedule

Furthermore, note also that Node.js 18 will fairly soon reach EOL.
…odule`

This allows *synchronous* loading of Node.js modules and (indirectly) packages, thus simplifying the code a fair bit.
…/display/node_stream.js` file

After the previous patch these base-classes are only extended once each and they can thus be combined with the final classes.
ryzokuken pushed a commit to ryzokuken/pdf.js that referenced this pull request Nov 4, 2024
The types tests run in Node.js and therefore use Node types for e.g.
builtins. However, we didn't explicitly indicate this in
`tsconfig.json` (see [1] for more information and [2] for the PR where
we found this). Moreover, we didn't explicitly install the most recent
version of `@types/node` which implicitly made us fall back to version
14.14.45 (because that was installed as a dependency of other modules)
whereas much newer versions are available and we need those after
changes in Node.js (see [3] for more information and [4] for the PR
where we found this).

This commit fixes both issues by explicitly installing and using the
most recent Node.js types, which should also avoid future issues with
the types tests.

[1] TypeStrong/ts-node#1012
[2] mozilla#18237
[3] https://stackoverflow.com/questions/78790943/in-typescript-5-6-buffer-is-not-assignable-to-arraybufferview-or-uint8arr
[4] mozilla#18959
@mozilla mozilla deleted a comment from moz-tools-bot Nov 4, 2024
@mozilla mozilla deleted a comment from moz-tools-bot Nov 4, 2024
@mozilla mozilla deleted a comment from moz-tools-bot Nov 4, 2024
@mozilla mozilla deleted a comment from moz-tools-bot Nov 4, 2024
@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Linux m4)


Received

Command cmd_test from @Snuffleupagus received. Current queue size: 0

Live output at: http://54.241.84.105:8877/f6cd146445c9fbe/output.txt

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Windows)


Received

Command cmd_test from @Snuffleupagus received. Current queue size: 0

Live output at: http://54.193.163.58:8877/8ff76d9de7c3070/output.txt

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Linux m4)


Failed

Full output at http://54.241.84.105:8877/f6cd146445c9fbe/output.txt

Total script time: 32.27 mins

  • Unit tests: Passed
  • Integration Tests: Passed
  • Regression tests: FAILED
  errors: 18
  different ref/snapshot: 20

Image differences available at: http://54.241.84.105:8877/f6cd146445c9fbe/reftest-analyzer.html#web=eq.log

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Windows)


Success

Full output at http://54.193.163.58:8877/8ff76d9de7c3070/output.txt

Total script time: 46.07 mins

  • Unit tests: Passed
  • Integration Tests: Passed
  • Regression tests: Passed

@Snuffleupagus Snuffleupagus merged commit cefd1eb into mozilla:master Nov 4, 2024
9 checks passed
@Snuffleupagus Snuffleupagus deleted the Node-20 branch November 4, 2024 09:29
@trungdq88
Copy link

This PR seems to break semver? If the minimum nodejs version is now 20, the package version should be now changed 5.x?

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

Successfully merging this pull request may close these issues.

4 participants