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

src,win: Replacement of unsupported versions of Windows runtime exit. #33108

Closed
wants to merge 9 commits into from
21 changes: 21 additions & 0 deletions src/node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,12 @@
#include <string>
#include <vector>

#ifdef _WIN32
#include <windows.h>
#include <VersionHelpers.h>
#include <WinError.h>
#endif

namespace node {

using native_module::NativeModuleEnv;
Expand Down Expand Up @@ -743,6 +749,21 @@ int ProcessGlobalArgs(std::vector<std::string>* args,
env_opts->abort_on_uncaught_exception = true;
}

#ifdef _WIN32
// Display a warning while using an unsupported version of Windows.
// Hide with --no-warnings options.
if (!per_process::cli_options->per_isolate->per_env->no_warnings) {
if (!IsWindows8Point1OrGreater() &&
!(IsWindowsServer() && IsWindows8OrGreater())) {
fprintf(stderr, "Node.js is only supported on Windows 8.1, "
"Windows Server 2012 R2, or higher. "
"Node.js will not accept bug reports "
"or patches while using unsupported "
"versions of Windows.\n\n");
}
}
#endif

// TODO(bnoordhuis) Intercept --prof arguments and start the CPU profiler
// manually? That would give us a little more control over its runtime
// behavior but it could also interfere with the user's intentions in ways
Expand Down
10 changes: 0 additions & 10 deletions src/node_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,9 @@

#ifdef _WIN32
#include <windows.h>
#include <VersionHelpers.h>
#include <WinError.h>

int wmain(int argc, wchar_t* wargv[]) {
// Windows Server 2012 (not R2) is supported until 10/10/2023, so we allow it
// to run in the experimental support tier.
if (!IsWindows8Point1OrGreater() &&
!(IsWindowsServer() && IsWindows8OrGreater())) {
fprintf(stderr, "This application is only supported on Windows 8.1, "
"Windows Server 2012 R2, or higher.");
exit(ERROR_EXE_MACHINE_TYPE_MISMATCH);
}

// Convert argv to UTF8
char** argv = new char*[argc + 1];
for (int i = 0; i < argc; i++) {
Expand Down
4 changes: 2 additions & 2 deletions tools/msvs/msi/product.wxs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
Compressed="yes"
InstallScope="perMachine"/>

<Condition Message="This application is only supported on Windows 8.1, Windows Server 2012 R2, or higher.">
<![CDATA[Installed OR (VersionNT >= 603) OR (VersionNT >= 602 AND MsiNTProductType <> 1)]]>
<Condition Message="This application will install on Windows 7, Windows Server 2008 R2, or higher, but is only supported on Windows 8.1, Windows Server 2012 R2, or higher.">
<![CDATA[Installed OR (VersionNT >= 601)]]>
xCykrix marked this conversation as resolved.
Show resolved Hide resolved
</Condition>

<Media Id="1" Cabinet="media1.cab" EmbedCab="yes"/>
Expand Down