Repository navigation
Load the mixed web example's IP Intelligence engine by package, and check what the location examples print - #95
Merged
Conversation
The mixed web example's 51d.json named the IP Intelligence engine by a path into the source folder next to the examples, ../../../../ipIntelligenceOnPremise. The Publish workflow's Test jobs install the packed packages and do not build the native modules in the source folder, so the engine loaded from that path found no build folder and "Examples without settings, the mixed web page marks the Enterprise properties" failed in every Test job. The Device Detection element in the same file already uses its package name. Naming the IP Intelligence engine the same way loads the installed package in the Publish jobs, the workspace package in a clone, and the npm package where the example is copied into a project.
The location examples read a global variable called resourceKey, which only a jest globals setting in location/package.json ever defined. The repository's jest projects do not set it, and a person running an example never has it, so every run printed a ReferenceError and its stack before going on to read the environment variable. examples.test.js evaluated each example and passed after one second whatever the example did, so the error never failed a test. The examples now read the key from the code or from the environment, and load fiftyone.geolocation by its package name instead of by a path set through process.env.directory, which only the old test set. The test runs each example in its own process from its own folder and fails unless the example exits with status 0, writes nothing to standard error and prints exactly the lines expected, with or without a resource key. The unused jest global is removed from both location manifests.
configureFromFile.js builds the path of 51d.json with path.join, as the lint rule n/no-path-concat asks now that the path starts at __dirname. The test no longer wraps its tests in describe, which the location lint settings do not declare. The resourceKey global is removed from location/.eslintrc, as nothing reads that variable now.
This was referenced Nov 13, 2026
jwrosewell
marked this pull request as ready for review
November 14, 2026 00:47
jwrosewell
added a commit
that referenced
this pull request
Nov 14, 2026
rc's #95 changed the location examples' key handling. combiningServices.js and gettingStarted.js take rc's code with the new address, and examples.test.js expects the new address in the message for a missing key.
This was referenced Nov 14, 2026
jwrosewell
added a commit
that referenced
this pull request
Nov 14, 2026
Eleven of the examples' `51d.json` files name an engine by a path into this repository's source, such as `"../../../deviceDetectionCloud"` in [`device-detection/fiftyone.devicedetection.cloud/examples/cloud/gettingstarted-console/51d.json` at fe81e01](https://github.com/51Degrees/51degrees-node/blob/fe81e01866b5aae0e2c6ec11a25a4f0a5d1ccd31/device-detection/fiftyone.devicedetection.cloud/examples/cloud/gettingstarted-console/51d.json). Such a file only works beside the source. [`ci/install-package.ps1` lines 43 to 55](https://github.com/51Degrees/51degrees-node/blob/fe81e01866b5aae0e2c6ec11a25a4f0a5d1ccd31/ci/install-package.ps1#L43-L55) rewrites two of them so the Publish tests run them against the packed packages, and [`device-detection/run_examples.md` lines 72 to 92](https://github.com/51Degrees/51degrees-node/blob/fe81e01866b5aae0e2c6ec11a25a4f0a5d1ccd31/device-detection/run_examples.md#L72-L92) and [`ip-intelligence/run_examples.md` lines 61 to 81](https://github.com/51Degrees/51degrees-node/blob/fe81e01866b5aae0e2c6ec11a25a4f0a5d1ccd31/ip-intelligence/run_examples.md#L61-L81) tell a person running an example against the published packages to edit the rest by hand. This is gap DX-node-20, left under "What remains" in [#95](#95), which named the mixed web example's engine by package.
jwrosewell
added a commit
that referenced
this pull request
Nov 14, 2026
… name what needs the Enterprise files (#111) The IP Intelligence mixed API example, which runs a local copy of the cloud service's API on both on-premise engines, does not run from a fresh clone as the other examples do (gap DX-node-29, left under "Not changed" in [#32](#32) and "What remains" in [#95](#95)). At [7539a0b](https://github.com/51Degrees/51degrees-node/tree/7539a0be284aec3e0aae12cf50cf727ead68fb4c):
Draft
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The Publish run for release 4.5.103, run 43412143722 on
mainat 4d5832f (the merge of #83), failed, so nothing was published and npm still has 4.5.102. In each of the eight "Publish / Test" jobs (Ubuntu, Ubuntu ARM, Windows and macOS, on Node.js 22 and 24) exactly one test failed, "Examples without settings › the mixed web page marks the Enterprise properties" inexamplesWithoutSettings.test.js.The same test passed in every job of the release build, run 43368219214, on the same code (8f14aa0).
The same Publish logs show
location/examples/examples.test.jsprintingReferenceError: resourceKey is not definedthree times, once from each example it runs, while every test in it passed.Cause
The mixed web example
nightly-publish.test.ps1, which clones this repository, runsci/setup-environment.ps1(npm install) and thenci/install-package.ps1. That script replaces each workspace link innode_moduleswith the files of the packed tarball, which carry the native modules. Nothing builds a native module in a source folder in those jobs, which is the point of them, because they test what was packed.mixed/gettingstarted-web/51d.jsonnamed the IP Intelligence engine../../../../ipIntelligenceOnPremise, a path to the source file. The test'swebOptionsturns a name starting with.into a path from the example's folder, sobuildFromConfigurationloadedip-intelligence/fiftyone.ipintelligence.onpremise/ipIntelligenceOnPremise.jsfrom the source folder. That file looks for its native module in its ownbuildfolder (lines 197 to 202), which a Build and Test job makes and a Publish Test job does not.require51('fiftyone.ipintelligence.onpremise')and does not use the element name in its51d.json, the console examples use the package, and the Device Detection element of the same mixed51d.jsonalready namesfiftyone.devicedetection.onpremise/deviceDetectionOnPremise. So the IP Intelligence element of the mixed web example was the only element in a test that named an engine with a native module by a source path. The cloud examples' source paths still load in a Publish job because their engines have no native module.elementNamein51d.jsonis a package path.The location examples
gettingStarted.js(lines 101 to 110),combiningServices.js(lines 52 to 61) andconfigureFromFile.js(lines 69 to 78) read a global variable calledresourceKeyinside atry, and print aReferenceErrorwithconsole.log(e). Only theglobalssetting of the jest configuration inlocation/package.jsondefined that variable. The location project in the rootpackage.jsondoes not, and a person running an example never has it, so every run printed the error and its stack before the example went on to read_51DEGREES_RESOURCE_KEY.examples.test.jsread each example, ran it witheval(line 51) and ended each test after one second withsetTimeout(done, 1000)(lines 65, 71 and 77). It checked nothing the examples printed, and the examples do not wait for their cloud call, so each test passed whatever the example did.So the examples and the test were both wrong.
What changed
mixed/gettingstarted-web/51d.jsonnames the enginefiftyone.ipintelligence.onpremise/ipIntelligenceOnPremise. In a clone, npm workspaces link that name to the source package, where the build step puts the native module. In a Publish job it is the installed package, and in a project that copies the example it is the npm package. The failing test is not changed and still runs. The mixed example's owngettingStarted.test.jsonly turns names starting with.into paths, so it takes the package name as it is.!!YOUR_RESOURCE_KEY!!, or from_51DEGREES_RESOURCE_KEY, and still readRESOURCE_KEYas the deprecated name with its warning, asci/tests/deprecatedVariableNames.test.jschecks. They loadfiftyone.geolocationby its package name, andconfigureFromFile.jsreads51d.jsonfrom its own folder withpath.join.webIntegration.jsloads the package the same way.process.env.directory, which only the old test set, is no longer read.location/examples/examples.test.jsruns each example in its own process from its own folder, asexamplesWithoutSettings.test.jsdoes, and fails unless the example exits with status 0, writes nothing to standard error and prints exactly the expected lines. With_51DEGREES_RESOURCE_KEYset it expects the country, and forcombiningServices.jsthe mobile answer as well. Without it, it expects the message that says where to create a key. Any other line, such as a caught error, fails the test. The deprecatedRESOURCE_KEYis taken out of the example's environment, so the name the test reads decides what it expects. Each example has 60 seconds and each test 120. Each example took under a second on Ubuntu (460 to 620 ms in run 43458115396 below), and every job passed within the limit.resourceKeyglobal is removed from the jest configuration inlocation/package.jsonandlocation/remote_package.json, and from the lint settings inlocation/.eslintrc.Package files
mixed/gettingstarted-web/51d.json. Thefileslist offiftyone.ipintelligence.onpremise(build,*.js,types) leaves outexamples, asnpm pack --dry-runin that folder shows, so the first commit changes no file in any npm package.fiftyone.geolocationpackage.location/package.jsonhas nofileslist, andnpm pack --dry-runinlocationincludes.eslintrcandexamples/with the four examples,examples.test.jsand51d.json. They also change thejestfield of thepackage.jsonin that package, whichci/build-package.ps1takes fromremote_package.json. They change no library file (index.js,geoLocationCloud.js,geoLocationPipelineBuilder.js), but thefiftyone.geolocationtarball is different. The first commit stands alone, so it can go without the other two.rcthat are not onmain(Say in AGENTS.md that a test failing on timing is fixed #93 and Point AGENTS.md at the one list of environment variable names #89) change only the rootAGENTS.mdandREADME.md, which no package carries.packageartifacts of the red and green Publish runs below were compared file by file. Both hold the same 16 tarballs at 4.5.103 with the same 424 files. The files whose contents differ are the 7 this pull request changes infiftyone.geolocation(.eslintrc,package.jsonand the five files underexamples/), and the 8 macOS and Windows native modules. Those 8 native modules also differ between the failed Publish run 43412143722 and the red run 43434654686, which were both built from 4d5832f, so they change on every build and not because of this pull request. The Linux native modules and every other file are identical. So with this pull request, Publish releases what it would have released for Release candidate #83, apart from thefiftyone.geolocationfiles above.How it was verified
Each run was started from a temporary branch, deleted afterwards. The Publish runs are this repository's Publish workflow with
dryruntrue. On a branch other thanmainthe Package job skipsnpm publish, and as a dry run it pushes no tag and creates no release.mainas it isexamplesWithoutSettings.test.jsandlocation/examples/examples.test.jspassing. The Package job ran as a dry run for the same 16 packages at 4.5.103 and logged "Not on the main branch, skipping publishing" and "Dry run - not pushing tag '4.5.103'".nightly-pull-request.ymlfor this pull request intorc, withdryruntrue,full-matrixtrue andfail-fastfalsePullRequestShaline reads 0468ed4. Each reports 2 skipped and 1355 passed for the unit tests, and 4 skipped and 132 passed for the integration tests.examples.test.json Ubuntu with Node.js 24 and the test resource key, first with the three examples as they are onrc, then as this pull request changes themReferenceError: resourceKey is not definedline and its stack that the example printed. After, 3 passed.Earlier runs on the first two commits (279ccb4) are superseded. The Publish dry run 43434662397 passed all eight Test jobs. The full build 43435057298 failed lint in all eight jobs (
n/no-path-concatinconfigureFromFile.jsanddescribenot defined inexamples.test.js), which the third commit fixes. The location check 43435056863 gave the same before and after results.Merge order
This draft and #87 both change four location examples,
combiningServices.js,configureFromFile.js,gettingStarted.jsandwebIntegration.js, and the two that conflict arecombiningServices.jsandgettingStarted.js. Also,location/examples/examples.test.jsline 44 here expects the old address,/^You need to create a resource key at https:\/\/configure\.51degrees\.com/, which #87 changes to https://51degrees.com/configure. That check runs only without a resource key, which CI always has, so CI cannot catch it. This draft merges first, and #87 then takesrcagain, resolves the two examples and changes that line to the new address.What remains
51d.jsonfiles still name an engine by a source path, being the cloud examples and Device Detection's on-premisegettingstarted-web. They load in a Publish job because cloud engines have no native module andci/install-package.ps1rewrites two of them, but the others run the source rather than the packed package, anddevice-detection/run_examples.mdandip-intelligence/run_examples.mdtell a person to change them by hand. Naming each engine by its package would remove both the rewrite and that step.device-detection/fiftyone.devicedetection/examples/gettingstarted.test.jsanddevice-detection/fiftyone.devicedetection.onpremise/examples/onpremise/performance-console/performance.test.jsuse the sameevalandsetTimeout(done, ...)pattern, so they pass whatever the example does.mixed/gettingstarted-api,mixed/gettingstarted-consoleandmixed/gettingstarted-web) skip themselves when they find no.hashfile in the IP Intelligencetestsfolder orcxx/data/ip-intelligence(tests/testHelper.jslines 32 to 35), andci/fetch-assets.ps1links the.hashfiles only into the Device Detection folders, so CI skips them. OnlyexamplesWithoutSettings.test.jsruns the mixed examples in CI.