Request error getaddrinfo enotfound

I recently came across this issue when using request-promise-native. When sending a GET or POST request to certain URLs, I received a "getaddrinfo ENOTFOUND" error. This seems to happen r...

Comments

@tyleri

ONS-Tom

added a commit
to ONSdigital/business-index-ui
that referenced
this issue

Oct 26, 2017

@ONS-Tom

ONS-Tom

added a commit
to ONSdigital/business-index-ui
that referenced
this issue

Nov 10, 2017

@ONS-Tom

* Fix server routes tests

* Fix Gitlab URL in Jenkinsfile

- Fix replacement URLs for Sed for API Gateway

* Fix Gitlab config to use correct branch

* Fix Gitlab credentialsId

* Remove POST body from 'prod' code

* Add testing code for using ENV variables

* Add debugging statements to node server

- For debugging in CF

* Change gitlab credentials back to bi

* Add json:true to node server request

* Add family:4 to request options in node server

- request/request-promise-native#6

* Remove hardcoded basicAuth values

* Fix search enpoint config

* Fix formQuery config, no need for & in query

* Remove debugging statements, console logs etc.

* Add logging config from sbr-ui

- Add filename to logs
- Use proper morgan logging with Winston logger

* Update Jenkinsfile with new configuration

- Build node 'GMU' label

* Add code for ShowConfetti, in server + frontend (#7)

- Copy showConfetti code from sbr-ui

awharris

added a commit
to ONSdigital/business-index-ui
that referenced
this issue

Jul 19, 2018

@awharris

* Feature/skeleton (#1)

* Add skeleton bi-ui frontend, mostly a clone of sbr-ui

- Cloned sbr-ui, replaced all sbr related code to bi, apart from apiActions

* Change apiActions to match business index format

* Add prototype UBRN search

* Add working UBRN search using react-table

* Add in pagination prop for UBRN results table

* Feature/range match search (#2)

* Fix validation for UBRN search

- Add config file for valid refs

* Add ONS inputs for Match search, used SDC styles

- Used Less to isolate SDC styles, prefix with 'sdc-isolation' to prevent conflicts with other styles

* Add inputs for Match search

- Add bands to utils/convertBands.js

* Add code for working Match search

- Uses all inputs

* Fix reload of Match data

- When going from match -> Home or another page, the data will be reloaded into the search inputs when you go back
- Turn off eslint rule

* Fix issue with clearing of Select boxes

* Remove UPRN field from Match page

* Add react-select input with working aria-hidden

- Use 'hacky' bit of js to fix buggy react-select component, on any update, look for classNames within react-select with an aria-hidden tag and change them
- Add filterable toggle (checkbox) to match search

* Refactor MatchForm, use seperate Components

- Move TextInput and SelectInput to seperate files
- Fix PropTypes

* Add scroll to results on search for Match

* Fix scroll to bottom on search feature

* Fix focus on first input after resetting the form

* Add minor fixes to UBRN page, naming etc.

* Fix naming of SearchRefForm -> UBRNForm

* Use CheckBoxInput component in Match

* Add fixed code for RangeSearch query

* Fix persistance of multiple select input values

* Fix bug for Clear button not clearing all the data

* Move SelectMultipleInput code to seperate file

* Add TextInputInline component for dual inputs

- i.e. for min/max inputs

* Fix use of filter props in RangeForm

* Add working RangeQuery search

- Add new formatter method in utils/formQuery.js
- Add (currently unused) consts in ApiConstants
- Fix apiAction for RangeQuery

* Fix formatRangeQuery, remove debugging statements

* Fix showFilter bug, shows after new search

* Transform businessName to upper case

* Add encodeSpecialChars method to formQuery

- For encoding businessName
- Copied method from business-index-ui

* Fix/initial refactor (#4)

* Add table of contents and description to README

* Fix README table of contents

* Add fix for redux reset store JSON issue

- See #3 for more details

* Add example expand view to Match

* Remove init query code to '' rather than {}

- This was causing bugs on refresh

* Fix/authentication (#5)

* Add mock API Gateway related code

- Copy from sbr-ui fix/authentication

* Migrate sbr-ui fix/authentication code to bi-ui

- Remove unused dependancies (jwt)
- Fix LoginActions/auth.js to mimick sbr-ui
- Add base64 encoding to LoginActions
- Use base64 for encoding username:password rather than bcrypt in the mock gateway
- Fix saving of accessToken in sessionStorage

* Fix rerouting of API requests to work for bi

- Change URL to localhost:9000 (business-index-api)

* Fix/deployment (#6)

* Fix server routes tests

* Fix Gitlab URL in Jenkinsfile

- Fix replacement URLs for Sed for API Gateway

* Fix Gitlab config to use correct branch

* Fix Gitlab credentialsId

* Remove POST body from 'prod' code

* Add testing code for using ENV variables

* Add debugging statements to node server

- For debugging in CF

* Change gitlab credentials back to bi

* Add json:true to node server request

* Add family:4 to request options in node server

- request/request-promise-native#6

* Remove hardcoded basicAuth values

* Fix search enpoint config

* Fix formQuery config, no need for & in query

* Remove debugging statements, console logs etc.

* Add logging config from sbr-ui

- Add filename to logs
- Use proper morgan logging with Winston logger

* Update Jenkinsfile with new configuration

- Build node 'GMU' label

* Add code for ShowConfetti, in server + frontend (#7)

- Copy showConfetti code from sbr-ui

* Fix/user feedback (#8)

* Add fix for PostCode on Match form

- Add value prop

* Add SummaryTable component for useful stats

- For num results + capped results

* Add ChildRefTable component for child references

- Not using Redux, just using fetch() inside the component

* Add siccodes conversion JSON

- Add SIC code conversion to expand view

* Add ResultsTable component

* Add additional props into ResultsTable

- DefaultPageSize, pagination etc.

* Fix clear functionality for UBRN search

- Focus on UBRN input after clear

* Remove comments, add config for /business endpoint

* Add proper formatting of ExpandView JSON

* Add Business Index description on Home page

* Fix Logout logic, handle 500's

- If there is a server error whilst logging out, the user will still be logged out

* Clear sessionStorage rather than localStorage

* Fix/console warnings (#9)

* Remove unused scripts from index.html

- Remove ONS JS & Jquery

* Fix key error in SummaryTable

* Fix role in reducer and node server

- Add 'role' back into login reducer
- Fix role returns in utils/auth.js
- Add role return into checkToken route in the node server

* Fix console warnings

- Unused imports etc.

* Fix propTypes errors

- Mostly related to the value prop

* Fix propType errors for ShowConfetti

* Add fix for IndustryCode inputs

- Use encoded square brackets

* Add fixes for industry code & refs bugs

- Fix use of industry code conversion
- Fix max number of refs not showing (bug in reduce function)

* Fix/cn expand view (#10)

* Add fix for CN display in helperMethods

* Remove debugging statement

* Feature/convert bands (#11)

* Add *bands conversion to ResultsTable

- Show the actual value rather than 'A' or '1' etc.

* Add checkBox for convertBands onto Match/Range

- Can toggle whether or not to use convertBands in the ResultsTable

* Fix passing of props to RangeForm

* Fix checkBoxes to be inline

- Use SDC grid

* Feature/export to csv (#12)

* Add export to csv functionality

- Using utils/export
- Copied from the business-index-ui

* Add config/export with name of CSV

* Add export to JSON button to ResultsTable

* Feature/ch link (#13)

* Add ch link in child refs table

* Add security fix for target="_blank"

* Fix/env vars (#14)

* Add new Jenkinsfile

* Update react-scripts so env vars can be used

- Update to 0.2.3 so we can use environment variables

* Use env vars for URLS in the frontend

* Add server environment variables

* Add updated Jenkinsfile

* Add debugging statements

* Remove debugging statements, fix Jenkinsfile

* Remove unused manifest.yml

* Fix/node server refactor (#15)

* Add refactored node server with seperate routes

- Move routes to /routes/...
- Do node config in index.js
- Use proper session management

* Refactor react code to integrate with new server

- For checkToken, put the token in an Authorization header

* Remove npm-run-script from package.json

* Fix README to include new running details

* Remove use of npm run script from Jenkinsfile

* Change server test config

- When you run npm run test-server, it will run the test that builds the project first, before running the other tests recursively in /server-test-spec

* Use test:type rathe than test-type

* Fix server tests, use seperate files

- The test:server runs the server.test.js first, which tests the npm run build command and the serving of static assets, the api/auth functionality are then tested, by recursively testing all files in /test/server-test-spec/*

* Remove unused component tests, unused dependancies

- Remove unused component tests + package.json test script
- Refactor dependancies in package.json, move test ones to devDeps

* Change order of routes import in node server

- Fix /version

* Fix static files path

- Fix start command in package.json

* Fix/jenkinsfile branch name (#16)

* Add fixed Jenkinsfile, fix branch names

* Change Gitlab branch to develop

* Fix/error handling 404 (#17)

* Add fix for 404 no results error

* Fix display of error message

- use () => method so closeModal isn't called every render

* Refactor scroll to top feature, reduce duplication

* Fix errorModal on Login form

* Add fix for range search

- Use proper encoded [ and ]

* Fix npm cover script, use correct server test

* Feature/redis sessions (#18)

* Add redis sessions to /sessions

- Remove component testing section on README
- Add redis-sessions dependancy
- Change /helpers to /utilities

* Add more to the README description

* Feature/search hoc (#19)

* Remove unused results key in Match/Range

- Remove commented out method in UBRNLookup

* Add Search Higher Order Component

- This makes the individual search pages (Match/Range/UBRN) redundant, as those pages use almost identical functionality, we can move all the common logic (all of it) into a higher order component, which returns a component based upon the input settings
- Modify UBRN redux action to handle commonality between match + range

* Move search pages config into /config/search

* Add comment into SearchHOC, explain use of HOC

* Fix console warning, unused var

* Add convert bands checkbox into UBRNForm

* Fix showFIlter, set false for UBRNForm

* Add fix for buggy showFilter

* Fix/search view grids (#20)

* Add refactored grid for UBRN & Range forms

- Use sdc grid to fit more inputs on the screen and handle smaller screen sizes

* Refactor MatchForm grid, condense inputs

* Remove unused grid helper div from Range grid

* Remove unused grid div from UBRNForm

* Remove unused BreadCrumb component

- Using the pattern library instead

* Remove unused DeveloperView component

* Remove unused CSS + JS

- Mostly bootstrap related

* Feature/highlight business name (#21)

* Add highlighting of businessName to ResultsTable

- Add prop businessName to be passed in to ResultsTable
- Add highlighting of businessName, using a <span> with a background colour

* Add try catch for creating the Regex

* Fix businessName prop to only update on a search

- Rather than the highlighting live updating as the user types, it will just do the highlighting when the search button is pressed

* Fix bug where highlighting is removed

- When changing between Match/Range/UBRN, the highlighting would dissapear

* Fix/results table key error (#22)

* Add reformatted ResultsTable code

- Add spacing to a large line of code to increase readability

* Add fix for key error in ResultsTable

- If there are multiple matches for the highlight method, a key error would occur due to duplicate keys, fix this by using an index counter as part of the key
- An ESLint key rule had to be disabled, however as the UBRN is used as part of the key it shouldn't be an issue

* Feature/health route (#23)

* Add /api/health route to the node server

- Just returns 'OK' for now

* Add extra details to comment on new route

* Add health check step to Jenkinsfile

* Change /api/health route to return JSON not text

* Add assignment of curl response status to variable

* Add build fail trigger to Check Health stage

* Fix/redux refactor (#24)

* Remove unused redux code

- Remove unused setPeriod action, SET_PERIOD constant and reducer code
- Remove large comments stating basic redux patterns
- Remove config files for periods

* Refactor setResults/Headers to not use JSON

- Just set the actual variable rather than nexting in JSON

* Refactor redux actions to be more concise

- Rather than defining an action for each type of search, use one action but pass in an additional value, in our case, the json key of a redux store item, so SET_QUERY with 'match' or 'range'

* Remove obvious redux related comments

- Don't need to explain what a reducer is etc.

* Remove verbose comments in redux actions

- Don't need to explain what an action is

* Remove unused error message related redux code

- Just the top level error message json key in the store, not the nested error messages in ubrn/match/range

* Remove unused timestamp from error message

* Refactor ApiAction to use generic action creator

- Rather than using UBRN/Match/Range actions, just use one generic action creator called search which will work for all search types
- Remove unused api searches in /utils/apiSearch

* Fix/utils unit tests (#25)

* Add convertBands unit tests

* Remove unused helper method (already in convert bands)

* Remove unused helperMethods

* Add helper methods unit test

* Remove flow annotations from /utils

- Not needed for such a small codebase, parameter types will be documented in JSDoc style doc strings

* Remove flow related configuration

- Remove dependancy from package.json
- Remove flow config file, .flowconfig

* Remove flow details in CONTRIBUTING.md

* Add unit test for Sic code conversion

* Fix/jenkinsfile manifest (#26)

* Add fix for using manifest based on branch name

* Remove promote to beta section of Jenkinsfile

* Update node + npm engines version in package.json

* Update Jenkinsfile to work with new CF

- Update deploy part of the script, new CF URL

* Remove unused API_GW_URL variable

* Fix Jenkinsfile to use actual Gitlab dir names

* Feature/dot env (#27)

* Add .env file for loading environment variables

- Add dotenv dependancy to package.json
- Update react-scripts to 0.5.1
- Remove env vars from package.json scripts (just start scripts)
- Move favicon and index.html to /public

* Remove env var section from README

- Fix mistake, change Bootstrap Isolation to SDC Isolation

* Update Jenkinsfile to handle .env config

* Update Jenkinsfile Gitlab branch

* Remove env vars from Jenkinsfile

- Use .env instead

* Use global Jenkins variable in place of local one

* Remove unused Jenkinsfile variables

* Fix tests to manually fork apiGateway script

* Add test user/pass env vars into test scripts

* Fix/ping health route (#28)

* Add --insecure flag to Jenkinsfile curl request

* Add documentation for new curl request flag

* Fix/export csv refactor (#29)

* Add refactored exportCSV method

* Refactor exportCSV code to improve readability

- Change name of config variable to be more intuitive

* Add documentation to methods in /utils/export.js

* Fix/api request refactor (#30)

* Remove unused onChange method from auth.js

* Add refactored fetch usage for searching

- Add accessAPI which is basically a helper to preset some commonly used config for fetch

* Add refactored InfoActions with new fetch

- Use accessAPI method in InfoActions

* Refactor login action to use accessAPI

* Add refactored logout LoginAction

* Add refactored logout action in LoginActions

* Remove unused /utils files

- Use default export in accessAPI.js

* Add more informative api request error messages

* Fix wrong last update usage in Info page

* Fix Jenkinsfile library branch

- Use master, not a deleted branch

* Feature/dockerfile (#31)

* Add Dockerfile and .dockerignore file

* Add env var to apiGateway config

- Use passed in env var for server url, so that we can pass in a docker url

* Remove misc notes from dockerfile

* Update README with better running instructions

* Update Jenkinsfile shared pipeline branch

* Fix/fetch promise refactor (#32)

* Add refactored fetch using promises

- Use promise rather than callback to make code more concise
- Leave in old accessAPI method until other *Actions are refactored

* Add refactore InfoActions using promises

- Fix bug where spinner would continue showing if an error had occured

* Fix bug relating to catching failed promises

* Remove old apiAccess method

- Refactor *Actions to use new accessAPI method

* Fix display of ErrorModal

- Convert to pure component
- Fix child ref table to use ApiAccess for API requests

* Feature/mock backend api (#33)

* Fix use of favicon in index.html

- Use properly formatted path

* Add fake request which mocks fetch

- All API requests pass the type of request (search/business/uiInfo etc) into accessAPI, so that URL's don't have to be parsed to find the endpoint
- Add /utils/request.js which will use the mocked fetch when it's in a test environment (REACT_APP_ENV)

* Make promise forming method more concise

* Move fakeFetch code into requestUtils

- Refactor code into small methods
- Fix ESLint error

* Add request dependancy to server package.json

* Remove unused bcrypt dependancy

* Reduce setTimeout when doing a fakeRequest

* Add .env file (remove from .gitignore)

* Fix/session classes (#34)

* Add proper use of OO inheritance in Sessions

- Each type of session extends the Session class
- Add documentation of Session methods
- Add pg dependancy to package.json

* Update Jenkinsfile Gitlab branch

* Fix PsqlSession pool creation bug

- Fix bug where just importing the PsqlSession class would trigger a new pool to be created, move this to an init method which is called from the constructor

* Remove unused CI.md README

* Feature/styles update (#35)

* Change REACT_APP_ENV value to 'test'

* Add assets for the new pattern library

- Add css to the /public directory
- Add logo image to /src/resources/img
- Remove old styles css import in index.js
- Update index.html to handle new CSS

* Remove unused dependancies, refactor ESLint

- Remove unused dependancies in package.json (react a11y)
- Remove unused eslint config section from package.json
- Add .vscode to .gitignore
- Remove unused routes

* Remove unused React components and utils

- Remove any unused views/components/helper methods
- Remove reducer/action/constant code relating to get ui/api info
- Remove unused config

* Fix ESLint issue with arrow functions

* Add updated Login page

- Add LoginAction for resetting the error message
- Add /patterns with Button/TextInput/LinkButton components
- Fix routes in routes file

* Refactor login page to use TextInput components

- Refactor TextInput to make it work with either refs or onChange

* Fix routing issue, refactor functional components

- Fix issue with SearchHOC (don't use it for now)

* Add Panel component for showing error/info/warn

* Add working search feature back in

- Add components to deal with the search (Business, ResultsList etc)
- Add redirect in ApiActions
- Fix exportJson method

* Fix industry code and multiple select inputs

* Remove unused files, refactor SearchHOC

- Remove unused assets
- Move onChange helpers to helperMethods for SearchHOC

* Fix issue with depracated replaceState params

* Fix documentation in all React classes

- Ensure documentation is consistent, e.g. no need to duplicate
prop details

* Refactor Redux related code, remove unused code

- Remove unused redux code (related to Match/range/ubrn)
- Move helper methods to /utils/helperMethods.js

* Fix documentation formatting

- Use consistent documentation format, where the parameters are only described where prop types isn't used

* Remove unused object.assign dependancy

* Remove verbose testing details from the README

* Add Pagination component and connect to Results

* Fix issue with <table> child, use <tbody>

- https://stackoverflow.com/questions/41716528/react-tr-cannot-appear-as-a-child-of-td-see-comment-td-tr

* Add ChildRefList component of child refs

* Fix ESLint errors

* Fix forming of the ES query

- Fix form query to work for generic queries
- Change env var back to local

* Use immutable set state, no mutating of state

- Use ES6 way of setting state immutably

* Add fix for searching on child ref (VAT/CH/PAYE)

* Fix use of plural businesses on Results page

* FIx issue with errorModal not showing on Home/Results

* Export helper method to fix unit test

* Add ESLint jsx-a11y to package.json to fix tests

* Fix https and password type issue

* Add type=text to SearchForm text inputs

* Add fix for text input sizes

* Remove sdc-main css (unused)

* Feature/styles update tests (#36)

* Add unit test for exportCSV method

* Add unit tests for formQuery

* Fix method and add test for formatData

* Add unit tests for other helperMethods code

* Fix/refs search (#37)

* Add fix for refs searching, add new fields

- Add new fields for CRN, VAT, PAYE search on SearchForm

* Remove unused code in formQuery.js

* Remove load test part of Jenkinsfile

* Add stress tests back in, fix unit test

* Add new unit tests for new formQuery inputs

* Fix/react 16 migration (#38)

* Add start of React 15 -> 15 migration

- Remove use of halogen for loading spinner, use fork which is compatible with react 16
- Upgrade react-router dependancy

* Fix use of React 16 for searching

- Fixed all features apart from 404 page and use of react-modal-dialog

* Fix 404 page display

* Refactor SearchForm to be functional component

* Change SearchForm to use props, no deconstruct

* Refactor code base to use Panel, not a modal

- Remove react-modal-dialog from package.json (not compatible with React 16 + we shouldn't be using it anyway)
- Refactor all uses of ErrorMessage to use a Panel instead
- Add props to Panel so that a close link can be used

* Feature/child refs hoc (#39)

* Refactor fetching of child refs into HOC

- ChildRefList/Table both have almost identical code for fetching /business/:id, so the common logic has been moved into a higher order component

* Add working use of HOC in ChildRefTable

* Fix/error modal bug (#40)

* Add fix for ChildRefList, use props not this.state

* Add fix for ChildRefTable, use props not state

* Fix/styles feedback fix (#43)

* Fix Button to use dynamic style/class props

- For the clear button, use secondary button type with border

* Remove username from Header.js

* Fix use of show references icons

- Add /img to /public
- Add chevron image to /src/resources

* Add capped badge if the results are capped

- Results cap at 10,000

* Add updated CSS for new search bar

* Seperate out SearchForm into different components

- Change props for button/textInput

* Add seperate search form for the home page

- Fix issue with TextInputInline not displaying the correct size

* Add fix for width of react-table (12 cols now)

* Fix column widths, fix issue with htmlFor in range input

* Fix more col widths, remove scroll in ResultsList

* Remove spacing from Home search inputs

* Fix spelling errors

- CN -> CRN
- Use 'Employment' instead of 'Employment Bands' in react table

* Add scroll to results feature

* Change scroll to go to Search header

* Feature/results capped at (#44)

* Add return of 'x-total-count' header

* Add display of panel showing number of results capped

- Add reducer/apiActions for setting capped results number
- Add allowed cors headers in the server for X-Total-Count
- Add return of X-Total-Count in apiGateway and api.js
- Modify accessApi.js to handle getting the headers

* Add unit test for new helperMethod

* Fix/mock fetch headers (#45)

* Add fix for mock fetch change of format

- From accessAPI we get a promise back with the response rather than a promise for the json

* Add better explanation of fetch issue

* Fix/export convert bands (#46)

* Add redux related code for exporting csv or json

* Add conversion of bands in csv/json download

* Use redux for the export of csv/json

* Add tests for export.js util

* Fix ESLint error (define before use)

* Fix/json fields update (#47)

* Fix JSON field accessor names

* Fix JSON fields in export.js

* Fix JSON fields for fake fetch functionality

* Fix tests with new JSON keys

awharris

added a commit
to ONSdigital/business-index-ui
that referenced
this issue

Sep 21, 2018

@awharris

* Feature/skeleton (#1)

* Add skeleton bi-ui frontend, mostly a clone of sbr-ui

- Cloned sbr-ui, replaced all sbr related code to bi, apart from apiActions

* Change apiActions to match business index format

* Add prototype UBRN search

* Add working UBRN search using react-table

* Add in pagination prop for UBRN results table

* Feature/range match search (#2)

* Fix validation for UBRN search

- Add config file for valid refs

* Add ONS inputs for Match search, used SDC styles

- Used Less to isolate SDC styles, prefix with 'sdc-isolation' to prevent conflicts with other styles

* Add inputs for Match search

- Add bands to utils/convertBands.js

* Add code for working Match search

- Uses all inputs

* Fix reload of Match data

- When going from match -> Home or another page, the data will be reloaded into the search inputs when you go back
- Turn off eslint rule

* Fix issue with clearing of Select boxes

* Remove UPRN field from Match page

* Add react-select input with working aria-hidden

- Use 'hacky' bit of js to fix buggy react-select component, on any update, look for classNames within react-select with an aria-hidden tag and change them
- Add filterable toggle (checkbox) to match search

* Refactor MatchForm, use seperate Components

- Move TextInput and SelectInput to seperate files
- Fix PropTypes

* Add scroll to results on search for Match

* Fix scroll to bottom on search feature

* Fix focus on first input after resetting the form

* Add minor fixes to UBRN page, naming etc.

* Fix naming of SearchRefForm -> UBRNForm

* Use CheckBoxInput component in Match

* Add fixed code for RangeSearch query

* Fix persistance of multiple select input values

* Fix bug for Clear button not clearing all the data

* Move SelectMultipleInput code to seperate file

* Add TextInputInline component for dual inputs

- i.e. for min/max inputs

* Fix use of filter props in RangeForm

* Add working RangeQuery search

- Add new formatter method in utils/formQuery.js
- Add (currently unused) consts in ApiConstants
- Fix apiAction for RangeQuery

* Fix formatRangeQuery, remove debugging statements

* Fix showFilter bug, shows after new search

* Transform businessName to upper case

* Add encodeSpecialChars method to formQuery

- For encoding businessName
- Copied method from business-index-ui

* Fix/initial refactor (#4)

* Add table of contents and description to README

* Fix README table of contents

* Add fix for redux reset store JSON issue

- See #3 for more details

* Add example expand view to Match

* Remove init query code to '' rather than {}

- This was causing bugs on refresh

* Fix/authentication (#5)

* Add mock API Gateway related code

- Copy from sbr-ui fix/authentication

* Migrate sbr-ui fix/authentication code to bi-ui

- Remove unused dependancies (jwt)
- Fix LoginActions/auth.js to mimick sbr-ui
- Add base64 encoding to LoginActions
- Use base64 for encoding username:password rather than bcrypt in the mock gateway
- Fix saving of accessToken in sessionStorage

* Fix rerouting of API requests to work for bi

- Change URL to localhost:9000 (business-index-api)

* Fix/deployment (#6)

* Fix server routes tests

* Fix Gitlab URL in Jenkinsfile

- Fix replacement URLs for Sed for API Gateway

* Fix Gitlab config to use correct branch

* Fix Gitlab credentialsId

* Remove POST body from 'prod' code

* Add testing code for using ENV variables

* Add debugging statements to node server

- For debugging in CF

* Change gitlab credentials back to bi

* Add json:true to node server request

* Add family:4 to request options in node server

- request/request-promise-native#6

* Remove hardcoded basicAuth values

* Fix search enpoint config

* Fix formQuery config, no need for & in query

* Remove debugging statements, console logs etc.

* Add logging config from sbr-ui

- Add filename to logs
- Use proper morgan logging with Winston logger

* Update Jenkinsfile with new configuration

- Build node 'GMU' label

* Add code for ShowConfetti, in server + frontend (#7)

- Copy showConfetti code from sbr-ui

* Fix/user feedback (#8)

* Add fix for PostCode on Match form

- Add value prop

* Add SummaryTable component for useful stats

- For num results + capped results

* Add ChildRefTable component for child references

- Not using Redux, just using fetch() inside the component

* Add siccodes conversion JSON

- Add SIC code conversion to expand view

* Add ResultsTable component

* Add additional props into ResultsTable

- DefaultPageSize, pagination etc.

* Fix clear functionality for UBRN search

- Focus on UBRN input after clear

* Remove comments, add config for /business endpoint

* Add proper formatting of ExpandView JSON

* Add Business Index description on Home page

* Fix Logout logic, handle 500's

- If there is a server error whilst logging out, the user will still be logged out

* Clear sessionStorage rather than localStorage

* Fix/console warnings (#9)

* Remove unused scripts from index.html

- Remove ONS JS & Jquery

* Fix key error in SummaryTable

* Fix role in reducer and node server

- Add 'role' back into login reducer
- Fix role returns in utils/auth.js
- Add role return into checkToken route in the node server

* Fix console warnings

- Unused imports etc.

* Fix propTypes errors

- Mostly related to the value prop

* Fix propType errors for ShowConfetti

* Add fix for IndustryCode inputs

- Use encoded square brackets

* Add fixes for industry code & refs bugs

- Fix use of industry code conversion
- Fix max number of refs not showing (bug in reduce function)

* Fix/cn expand view (#10)

* Add fix for CN display in helperMethods

* Remove debugging statement

* Feature/convert bands (#11)

* Add *bands conversion to ResultsTable

- Show the actual value rather than 'A' or '1' etc.

* Add checkBox for convertBands onto Match/Range

- Can toggle whether or not to use convertBands in the ResultsTable

* Fix passing of props to RangeForm

* Fix checkBoxes to be inline

- Use SDC grid

* Feature/export to csv (#12)

* Add export to csv functionality

- Using utils/export
- Copied from the business-index-ui

* Add config/export with name of CSV

* Add export to JSON button to ResultsTable

* Feature/ch link (#13)

* Add ch link in child refs table

* Add security fix for target="_blank"

* Fix/env vars (#14)

* Add new Jenkinsfile

* Update react-scripts so env vars can be used

- Update to 0.2.3 so we can use environment variables

* Use env vars for URLS in the frontend

* Add server environment variables

* Add updated Jenkinsfile

* Add debugging statements

* Remove debugging statements, fix Jenkinsfile

* Remove unused manifest.yml

* Fix/node server refactor (#15)

* Add refactored node server with seperate routes

- Move routes to /routes/...
- Do node config in index.js
- Use proper session management

* Refactor react code to integrate with new server

- For checkToken, put the token in an Authorization header

* Remove npm-run-script from package.json

* Fix README to include new running details

* Remove use of npm run script from Jenkinsfile

* Change server test config

- When you run npm run test-server, it will run the test that builds the project first, before running the other tests recursively in /server-test-spec

* Use test:type rathe than test-type

* Fix server tests, use seperate files

- The test:server runs the server.test.js first, which tests the npm run build command and the serving of static assets, the api/auth functionality are then tested, by recursively testing all files in /test/server-test-spec/*

* Remove unused component tests, unused dependancies

- Remove unused component tests + package.json test script
- Refactor dependancies in package.json, move test ones to devDeps

* Change order of routes import in node server

- Fix /version

* Fix static files path

- Fix start command in package.json

* Fix/jenkinsfile branch name (#16)

* Add fixed Jenkinsfile, fix branch names

* Change Gitlab branch to develop

* Fix/error handling 404 (#17)

* Add fix for 404 no results error

* Fix display of error message

- use () => method so closeModal isn't called every render

* Refactor scroll to top feature, reduce duplication

* Fix errorModal on Login form

* Add fix for range search

- Use proper encoded [ and ]

* Fix npm cover script, use correct server test

* Feature/redis sessions (#18)

* Add redis sessions to /sessions

- Remove component testing section on README
- Add redis-sessions dependancy
- Change /helpers to /utilities

* Add more to the README description

* Feature/search hoc (#19)

* Remove unused results key in Match/Range

- Remove commented out method in UBRNLookup

* Add Search Higher Order Component

- This makes the individual search pages (Match/Range/UBRN) redundant, as those pages use almost identical functionality, we can move all the common logic (all of it) into a higher order component, which returns a component based upon the input settings
- Modify UBRN redux action to handle commonality between match + range

* Move search pages config into /config/search

* Add comment into SearchHOC, explain use of HOC

* Fix console warning, unused var

* Add convert bands checkbox into UBRNForm

* Fix showFIlter, set false for UBRNForm

* Add fix for buggy showFilter

* Fix/search view grids (#20)

* Add refactored grid for UBRN & Range forms

- Use sdc grid to fit more inputs on the screen and handle smaller screen sizes

* Refactor MatchForm grid, condense inputs

* Remove unused grid helper div from Range grid

* Remove unused grid div from UBRNForm

* Remove unused BreadCrumb component

- Using the pattern library instead

* Remove unused DeveloperView component

* Remove unused CSS + JS

- Mostly bootstrap related

* Feature/highlight business name (#21)

* Add highlighting of businessName to ResultsTable

- Add prop businessName to be passed in to ResultsTable
- Add highlighting of businessName, using a <span> with a background colour

* Add try catch for creating the Regex

* Fix businessName prop to only update on a search

- Rather than the highlighting live updating as the user types, it will just do the highlighting when the search button is pressed

* Fix bug where highlighting is removed

- When changing between Match/Range/UBRN, the highlighting would dissapear

* Fix/results table key error (#22)

* Add reformatted ResultsTable code

- Add spacing to a large line of code to increase readability

* Add fix for key error in ResultsTable

- If there are multiple matches for the highlight method, a key error would occur due to duplicate keys, fix this by using an index counter as part of the key
- An ESLint key rule had to be disabled, however as the UBRN is used as part of the key it shouldn't be an issue

* Feature/health route (#23)

* Add /api/health route to the node server

- Just returns 'OK' for now

* Add extra details to comment on new route

* Add health check step to Jenkinsfile

* Change /api/health route to return JSON not text

* Add assignment of curl response status to variable

* Add build fail trigger to Check Health stage

* Fix/redux refactor (#24)

* Remove unused redux code

- Remove unused setPeriod action, SET_PERIOD constant and reducer code
- Remove large comments stating basic redux patterns
- Remove config files for periods

* Refactor setResults/Headers to not use JSON

- Just set the actual variable rather than nexting in JSON

* Refactor redux actions to be more concise

- Rather than defining an action for each type of search, use one action but pass in an additional value, in our case, the json key of a redux store item, so SET_QUERY with 'match' or 'range'

* Remove obvious redux related comments

- Don't need to explain what a reducer is etc.

* Remove verbose comments in redux actions

- Don't need to explain what an action is

* Remove unused error message related redux code

- Just the top level error message json key in the store, not the nested error messages in ubrn/match/range

* Remove unused timestamp from error message

* Refactor ApiAction to use generic action creator

- Rather than using UBRN/Match/Range actions, just use one generic action creator called search which will work for all search types
- Remove unused api searches in /utils/apiSearch

* Fix/utils unit tests (#25)

* Add convertBands unit tests

* Remove unused helper method (already in convert bands)

* Remove unused helperMethods

* Add helper methods unit test

* Remove flow annotations from /utils

- Not needed for such a small codebase, parameter types will be documented in JSDoc style doc strings

* Remove flow related configuration

- Remove dependancy from package.json
- Remove flow config file, .flowconfig

* Remove flow details in CONTRIBUTING.md

* Add unit test for Sic code conversion

* Fix/jenkinsfile manifest (#26)

* Add fix for using manifest based on branch name

* Remove promote to beta section of Jenkinsfile

* Update node + npm engines version in package.json

* Update Jenkinsfile to work with new CF

- Update deploy part of the script, new CF URL

* Remove unused API_GW_URL variable

* Fix Jenkinsfile to use actual Gitlab dir names

* Feature/dot env (#27)

* Add .env file for loading environment variables

- Add dotenv dependancy to package.json
- Update react-scripts to 0.5.1
- Remove env vars from package.json scripts (just start scripts)
- Move favicon and index.html to /public

* Remove env var section from README

- Fix mistake, change Bootstrap Isolation to SDC Isolation

* Update Jenkinsfile to handle .env config

* Update Jenkinsfile Gitlab branch

* Remove env vars from Jenkinsfile

- Use .env instead

* Use global Jenkins variable in place of local one

* Remove unused Jenkinsfile variables

* Fix tests to manually fork apiGateway script

* Add test user/pass env vars into test scripts

* Fix/ping health route (#28)

* Add --insecure flag to Jenkinsfile curl request

* Add documentation for new curl request flag

* Fix/export csv refactor (#29)

* Add refactored exportCSV method

* Refactor exportCSV code to improve readability

- Change name of config variable to be more intuitive

* Add documentation to methods in /utils/export.js

* Fix/api request refactor (#30)

* Remove unused onChange method from auth.js

* Add refactored fetch usage for searching

- Add accessAPI which is basically a helper to preset some commonly used config for fetch

* Add refactored InfoActions with new fetch

- Use accessAPI method in InfoActions

* Refactor login action to use accessAPI

* Add refactored logout LoginAction

* Add refactored logout action in LoginActions

* Remove unused /utils files

- Use default export in accessAPI.js

* Add more informative api request error messages

* Fix wrong last update usage in Info page

* Fix Jenkinsfile library branch

- Use master, not a deleted branch

* Feature/dockerfile (#31)

* Add Dockerfile and .dockerignore file

* Add env var to apiGateway config

- Use passed in env var for server url, so that we can pass in a docker url

* Remove misc notes from dockerfile

* Update README with better running instructions

* Update Jenkinsfile shared pipeline branch

* Fix/fetch promise refactor (#32)

* Add refactored fetch using promises

- Use promise rather than callback to make code more concise
- Leave in old accessAPI method until other *Actions are refactored

* Add refactore InfoActions using promises

- Fix bug where spinner would continue showing if an error had occured

* Fix bug relating to catching failed promises

* Remove old apiAccess method

- Refactor *Actions to use new accessAPI method

* Fix display of ErrorModal

- Convert to pure component
- Fix child ref table to use ApiAccess for API requests

* Feature/mock backend api (#33)

* Fix use of favicon in index.html

- Use properly formatted path

* Add fake request which mocks fetch

- All API requests pass the type of request (search/business/uiInfo etc) into accessAPI, so that URL's don't have to be parsed to find the endpoint
- Add /utils/request.js which will use the mocked fetch when it's in a test environment (REACT_APP_ENV)

* Make promise forming method more concise

* Move fakeFetch code into requestUtils

- Refactor code into small methods
- Fix ESLint error

* Add request dependancy to server package.json

* Remove unused bcrypt dependancy

* Reduce setTimeout when doing a fakeRequest

* Add .env file (remove from .gitignore)

* Fix/session classes (#34)

* Add proper use of OO inheritance in Sessions

- Each type of session extends the Session class
- Add documentation of Session methods
- Add pg dependancy to package.json

* Update Jenkinsfile Gitlab branch

* Fix PsqlSession pool creation bug

- Fix bug where just importing the PsqlSession class would trigger a new pool to be created, move this to an init method which is called from the constructor

* Remove unused CI.md README

* Feature/styles update (#35)

* Change REACT_APP_ENV value to 'test'

* Add assets for the new pattern library

- Add css to the /public directory
- Add logo image to /src/resources/img
- Remove old styles css import in index.js
- Update index.html to handle new CSS

* Remove unused dependancies, refactor ESLint

- Remove unused dependancies in package.json (react a11y)
- Remove unused eslint config section from package.json
- Add .vscode to .gitignore
- Remove unused routes

* Remove unused React components and utils

- Remove any unused views/components/helper methods
- Remove reducer/action/constant code relating to get ui/api info
- Remove unused config

* Fix ESLint issue with arrow functions

* Add updated Login page

- Add LoginAction for resetting the error message
- Add /patterns with Button/TextInput/LinkButton components
- Fix routes in routes file

* Refactor login page to use TextInput components

- Refactor TextInput to make it work with either refs or onChange

* Fix routing issue, refactor functional components

- Fix issue with SearchHOC (don't use it for now)

* Add Panel component for showing error/info/warn

* Add working search feature back in

- Add components to deal with the search (Business, ResultsList etc)
- Add redirect in ApiActions
- Fix exportJson method

* Fix industry code and multiple select inputs

* Remove unused files, refactor SearchHOC

- Remove unused assets
- Move onChange helpers to helperMethods for SearchHOC

* Fix issue with depracated replaceState params

* Fix documentation in all React classes

- Ensure documentation is consistent, e.g. no need to duplicate
prop details

* Refactor Redux related code, remove unused code

- Remove unused redux code (related to Match/range/ubrn)
- Move helper methods to /utils/helperMethods.js

* Fix documentation formatting

- Use consistent documentation format, where the parameters are only described where prop types isn't used

* Remove unused object.assign dependancy

* Remove verbose testing details from the README

* Add Pagination component and connect to Results

* Fix issue with <table> child, use <tbody>

- https://stackoverflow.com/questions/41716528/react-tr-cannot-appear-as-a-child-of-td-see-comment-td-tr

* Add ChildRefList component of child refs

* Fix ESLint errors

* Fix forming of the ES query

- Fix form query to work for generic queries
- Change env var back to local

* Use immutable set state, no mutating of state

- Use ES6 way of setting state immutably

* Add fix for searching on child ref (VAT/CH/PAYE)

* Fix use of plural businesses on Results page

* FIx issue with errorModal not showing on Home/Results

* Export helper method to fix unit test

* Add ESLint jsx-a11y to package.json to fix tests

* Fix https and password type issue

* Add type=text to SearchForm text inputs

* Add fix for text input sizes

* Remove sdc-main css (unused)

* Feature/styles update tests (#36)

* Add unit test for exportCSV method

* Add unit tests for formQuery

* Fix method and add test for formatData

* Add unit tests for other helperMethods code

* Fix/refs search (#37)

* Add fix for refs searching, add new fields

- Add new fields for CRN, VAT, PAYE search on SearchForm

* Remove unused code in formQuery.js

* Remove load test part of Jenkinsfile

* Add stress tests back in, fix unit test

* Add new unit tests for new formQuery inputs

* Fix/react 16 migration (#38)

* Add start of React 15 -> 15 migration

- Remove use of halogen for loading spinner, use fork which is compatible with react 16
- Upgrade react-router dependancy

* Fix use of React 16 for searching

- Fixed all features apart from 404 page and use of react-modal-dialog

* Fix 404 page display

* Refactor SearchForm to be functional component

* Change SearchForm to use props, no deconstruct

* Refactor code base to use Panel, not a modal

- Remove react-modal-dialog from package.json (not compatible with React 16 + we shouldn't be using it anyway)
- Refactor all uses of ErrorMessage to use a Panel instead
- Add props to Panel so that a close link can be used

* Feature/child refs hoc (#39)

* Refactor fetching of child refs into HOC

- ChildRefList/Table both have almost identical code for fetching /business/:id, so the common logic has been moved into a higher order component

* Add working use of HOC in ChildRefTable

* Fix/error modal bug (#40)

* Add fix for ChildRefList, use props not this.state

* Add fix for ChildRefTable, use props not state

* Fix/styles feedback fix (#43)

* Fix Button to use dynamic style/class props

- For the clear button, use secondary button type with border

* Remove username from Header.js

* Fix use of show references icons

- Add /img to /public
- Add chevron image to /src/resources

* Add capped badge if the results are capped

- Results cap at 10,000

* Add updated CSS for new search bar

* Seperate out SearchForm into different components

- Change props for button/textInput

* Add seperate search form for the home page

- Fix issue with TextInputInline not displaying the correct size

* Add fix for width of react-table (12 cols now)

* Fix column widths, fix issue with htmlFor in range input

* Fix more col widths, remove scroll in ResultsList

* Remove spacing from Home search inputs

* Fix spelling errors

- CN -> CRN
- Use 'Employment' instead of 'Employment Bands' in react table

* Add scroll to results feature

* Change scroll to go to Search header

* Feature/results capped at (#44)

* Add return of 'x-total-count' header

* Add display of panel showing number of results capped

- Add reducer/apiActions for setting capped results number
- Add allowed cors headers in the server for X-Total-Count
- Add return of X-Total-Count in apiGateway and api.js
- Modify accessApi.js to handle getting the headers

* Add unit test for new helperMethod

* Fix/mock fetch headers (#45)

* Add fix for mock fetch change of format

- From accessAPI we get a promise back with the response rather than a promise for the json

* Add better explanation of fetch issue

* Fix/export convert bands (#46)

* Add redux related code for exporting csv or json

* Add conversion of bands in csv/json download

* Use redux for the export of csv/json

* Add tests for export.js util

* Fix ESLint error (define before use)

* Fix/json fields update (#47)

* Fix JSON field accessor names

* Fix JSON fields in export.js

* Fix JSON fields for fake fetch functionality

* Fix tests with new JSON keys

awharris

added a commit
to ONSdigital/business-index-ui
that referenced
this issue

Sep 21, 2018

@awharris

* Feature/skeleton (#1)

* Add skeleton bi-ui frontend, mostly a clone of sbr-ui

- Cloned sbr-ui, replaced all sbr related code to bi, apart from apiActions

* Change apiActions to match business index format

* Add prototype UBRN search

* Add working UBRN search using react-table

* Add in pagination prop for UBRN results table

* Feature/range match search (#2)

* Fix validation for UBRN search

- Add config file for valid refs

* Add ONS inputs for Match search, used SDC styles

- Used Less to isolate SDC styles, prefix with 'sdc-isolation' to prevent conflicts with other styles

* Add inputs for Match search

- Add bands to utils/convertBands.js

* Add code for working Match search

- Uses all inputs

* Fix reload of Match data

- When going from match -> Home or another page, the data will be reloaded into the search inputs when you go back
- Turn off eslint rule

* Fix issue with clearing of Select boxes

* Remove UPRN field from Match page

* Add react-select input with working aria-hidden

- Use 'hacky' bit of js to fix buggy react-select component, on any update, look for classNames within react-select with an aria-hidden tag and change them
- Add filterable toggle (checkbox) to match search

* Refactor MatchForm, use seperate Components

- Move TextInput and SelectInput to seperate files
- Fix PropTypes

* Add scroll to results on search for Match

* Fix scroll to bottom on search feature

* Fix focus on first input after resetting the form

* Add minor fixes to UBRN page, naming etc.

* Fix naming of SearchRefForm -> UBRNForm

* Use CheckBoxInput component in Match

* Add fixed code for RangeSearch query

* Fix persistance of multiple select input values

* Fix bug for Clear button not clearing all the data

* Move SelectMultipleInput code to seperate file

* Add TextInputInline component for dual inputs

- i.e. for min/max inputs

* Fix use of filter props in RangeForm

* Add working RangeQuery search

- Add new formatter method in utils/formQuery.js
- Add (currently unused) consts in ApiConstants
- Fix apiAction for RangeQuery

* Fix formatRangeQuery, remove debugging statements

* Fix showFilter bug, shows after new search

* Transform businessName to upper case

* Add encodeSpecialChars method to formQuery

- For encoding businessName
- Copied method from business-index-ui

* Fix/initial refactor (#4)

* Add table of contents and description to README

* Fix README table of contents

* Add fix for redux reset store JSON issue

- See #3 for more details

* Add example expand view to Match

* Remove init query code to '' rather than {}

- This was causing bugs on refresh

* Fix/authentication (#5)

* Add mock API Gateway related code

- Copy from sbr-ui fix/authentication

* Migrate sbr-ui fix/authentication code to bi-ui

- Remove unused dependancies (jwt)
- Fix LoginActions/auth.js to mimick sbr-ui
- Add base64 encoding to LoginActions
- Use base64 for encoding username:password rather than bcrypt in the mock gateway
- Fix saving of accessToken in sessionStorage

* Fix rerouting of API requests to work for bi

- Change URL to localhost:9000 (business-index-api)

* Fix/deployment (#6)

* Fix server routes tests

* Fix Gitlab URL in Jenkinsfile

- Fix replacement URLs for Sed for API Gateway

* Fix Gitlab config to use correct branch

* Fix Gitlab credentialsId

* Remove POST body from 'prod' code

* Add testing code for using ENV variables

* Add debugging statements to node server

- For debugging in CF

* Change gitlab credentials back to bi

* Add json:true to node server request

* Add family:4 to request options in node server

- request/request-promise-native#6

* Remove hardcoded basicAuth values

* Fix search enpoint config

* Fix formQuery config, no need for & in query

* Remove debugging statements, console logs etc.

* Add logging config from sbr-ui

- Add filename to logs
- Use proper morgan logging with Winston logger

* Update Jenkinsfile with new configuration

- Build node 'GMU' label

* Add code for ShowConfetti, in server + frontend (#7)

- Copy showConfetti code from sbr-ui

* Fix/user feedback (#8)

* Add fix for PostCode on Match form

- Add value prop

* Add SummaryTable component for useful stats

- For num results + capped results

* Add ChildRefTable component for child references

- Not using Redux, just using fetch() inside the component

* Add siccodes conversion JSON

- Add SIC code conversion to expand view

* Add ResultsTable component

* Add additional props into ResultsTable

- DefaultPageSize, pagination etc.

* Fix clear functionality for UBRN search

- Focus on UBRN input after clear

* Remove comments, add config for /business endpoint

* Add proper formatting of ExpandView JSON

* Add Business Index description on Home page

* Fix Logout logic, handle 500's

- If there is a server error whilst logging out, the user will still be logged out

* Clear sessionStorage rather than localStorage

* Fix/console warnings (#9)

* Remove unused scripts from index.html

- Remove ONS JS & Jquery

* Fix key error in SummaryTable

* Fix role in reducer and node server

- Add 'role' back into login reducer
- Fix role returns in utils/auth.js
- Add role return into checkToken route in the node server

* Fix console warnings

- Unused imports etc.

* Fix propTypes errors

- Mostly related to the value prop

* Fix propType errors for ShowConfetti

* Add fix for IndustryCode inputs

- Use encoded square brackets

* Add fixes for industry code & refs bugs

- Fix use of industry code conversion
- Fix max number of refs not showing (bug in reduce function)

* Fix/cn expand view (#10)

* Add fix for CN display in helperMethods

* Remove debugging statement

* Feature/convert bands (#11)

* Add *bands conversion to ResultsTable

- Show the actual value rather than 'A' or '1' etc.

* Add checkBox for convertBands onto Match/Range

- Can toggle whether or not to use convertBands in the ResultsTable

* Fix passing of props to RangeForm

* Fix checkBoxes to be inline

- Use SDC grid

* Feature/export to csv (#12)

* Add export to csv functionality

- Using utils/export
- Copied from the business-index-ui

* Add config/export with name of CSV

* Add export to JSON button to ResultsTable

* Feature/ch link (#13)

* Add ch link in child refs table

* Add security fix for target="_blank"

* Fix/env vars (#14)

* Add new Jenkinsfile

* Update react-scripts so env vars can be used

- Update to 0.2.3 so we can use environment variables

* Use env vars for URLS in the frontend

* Add server environment variables

* Add updated Jenkinsfile

* Add debugging statements

* Remove debugging statements, fix Jenkinsfile

* Remove unused manifest.yml

* Fix/node server refactor (#15)

* Add refactored node server with seperate routes

- Move routes to /routes/...
- Do node config in index.js
- Use proper session management

* Refactor react code to integrate with new server

- For checkToken, put the token in an Authorization header

* Remove npm-run-script from package.json

* Fix README to include new running details

* Remove use of npm run script from Jenkinsfile

* Change server test config

- When you run npm run test-server, it will run the test that builds the project first, before running the other tests recursively in /server-test-spec

* Use test:type rathe than test-type

* Fix server tests, use seperate files

- The test:server runs the server.test.js first, which tests the npm run build command and the serving of static assets, the api/auth functionality are then tested, by recursively testing all files in /test/server-test-spec/*

* Remove unused component tests, unused dependancies

- Remove unused component tests + package.json test script
- Refactor dependancies in package.json, move test ones to devDeps

* Change order of routes import in node server

- Fix /version

* Fix static files path

- Fix start command in package.json

* Fix/jenkinsfile branch name (#16)

* Add fixed Jenkinsfile, fix branch names

* Change Gitlab branch to develop

* Fix/error handling 404 (#17)

* Add fix for 404 no results error

* Fix display of error message

- use () => method so closeModal isn't called every render

* Refactor scroll to top feature, reduce duplication

* Fix errorModal on Login form

* Add fix for range search

- Use proper encoded [ and ]

* Fix npm cover script, use correct server test

* Feature/redis sessions (#18)

* Add redis sessions to /sessions

- Remove component testing section on README
- Add redis-sessions dependancy
- Change /helpers to /utilities

* Add more to the README description

* Feature/search hoc (#19)

* Remove unused results key in Match/Range

- Remove commented out method in UBRNLookup

* Add Search Higher Order Component

- This makes the individual search pages (Match/Range/UBRN) redundant, as those pages use almost identical functionality, we can move all the common logic (all of it) into a higher order component, which returns a component based upon the input settings
- Modify UBRN redux action to handle commonality between match + range

* Move search pages config into /config/search

* Add comment into SearchHOC, explain use of HOC

* Fix console warning, unused var

* Add convert bands checkbox into UBRNForm

* Fix showFIlter, set false for UBRNForm

* Add fix for buggy showFilter

* Fix/search view grids (#20)

* Add refactored grid for UBRN & Range forms

- Use sdc grid to fit more inputs on the screen and handle smaller screen sizes

* Refactor MatchForm grid, condense inputs

* Remove unused grid helper div from Range grid

* Remove unused grid div from UBRNForm

* Remove unused BreadCrumb component

- Using the pattern library instead

* Remove unused DeveloperView component

* Remove unused CSS + JS

- Mostly bootstrap related

* Feature/highlight business name (#21)

* Add highlighting of businessName to ResultsTable

- Add prop businessName to be passed in to ResultsTable
- Add highlighting of businessName, using a <span> with a background colour

* Add try catch for creating the Regex

* Fix businessName prop to only update on a search

- Rather than the highlighting live updating as the user types, it will just do the highlighting when the search button is pressed

* Fix bug where highlighting is removed

- When changing between Match/Range/UBRN, the highlighting would dissapear

* Fix/results table key error (#22)

* Add reformatted ResultsTable code

- Add spacing to a large line of code to increase readability

* Add fix for key error in ResultsTable

- If there are multiple matches for the highlight method, a key error would occur due to duplicate keys, fix this by using an index counter as part of the key
- An ESLint key rule had to be disabled, however as the UBRN is used as part of the key it shouldn't be an issue

* Feature/health route (#23)

* Add /api/health route to the node server

- Just returns 'OK' for now

* Add extra details to comment on new route

* Add health check step to Jenkinsfile

* Change /api/health route to return JSON not text

* Add assignment of curl response status to variable

* Add build fail trigger to Check Health stage

* Fix/redux refactor (#24)

* Remove unused redux code

- Remove unused setPeriod action, SET_PERIOD constant and reducer code
- Remove large comments stating basic redux patterns
- Remove config files for periods

* Refactor setResults/Headers to not use JSON

- Just set the actual variable rather than nexting in JSON

* Refactor redux actions to be more concise

- Rather than defining an action for each type of search, use one action but pass in an additional value, in our case, the json key of a redux store item, so SET_QUERY with 'match' or 'range'

* Remove obvious redux related comments

- Don't need to explain what a reducer is etc.

* Remove verbose comments in redux actions

- Don't need to explain what an action is

* Remove unused error message related redux code

- Just the top level error message json key in the store, not the nested error messages in ubrn/match/range

* Remove unused timestamp from error message

* Refactor ApiAction to use generic action creator

- Rather than using UBRN/Match/Range actions, just use one generic action creator called search which will work for all search types
- Remove unused api searches in /utils/apiSearch

* Fix/utils unit tests (#25)

* Add convertBands unit tests

* Remove unused helper method (already in convert bands)

* Remove unused helperMethods

* Add helper methods unit test

* Remove flow annotations from /utils

- Not needed for such a small codebase, parameter types will be documented in JSDoc style doc strings

* Remove flow related configuration

- Remove dependancy from package.json
- Remove flow config file, .flowconfig

* Remove flow details in CONTRIBUTING.md

* Add unit test for Sic code conversion

* Fix/jenkinsfile manifest (#26)

* Add fix for using manifest based on branch name

* Remove promote to beta section of Jenkinsfile

* Update node + npm engines version in package.json

* Update Jenkinsfile to work with new CF

- Update deploy part of the script, new CF URL

* Remove unused API_GW_URL variable

* Fix Jenkinsfile to use actual Gitlab dir names

* Feature/dot env (#27)

* Add .env file for loading environment variables

- Add dotenv dependancy to package.json
- Update react-scripts to 0.5.1
- Remove env vars from package.json scripts (just start scripts)
- Move favicon and index.html to /public

* Remove env var section from README

- Fix mistake, change Bootstrap Isolation to SDC Isolation

* Update Jenkinsfile to handle .env config

* Update Jenkinsfile Gitlab branch

* Remove env vars from Jenkinsfile

- Use .env instead

* Use global Jenkins variable in place of local one

* Remove unused Jenkinsfile variables

* Fix tests to manually fork apiGateway script

* Add test user/pass env vars into test scripts

* Fix/ping health route (#28)

* Add --insecure flag to Jenkinsfile curl request

* Add documentation for new curl request flag

* Fix/export csv refactor (#29)

* Add refactored exportCSV method

* Refactor exportCSV code to improve readability

- Change name of config variable to be more intuitive

* Add documentation to methods in /utils/export.js

* Fix/api request refactor (#30)

* Remove unused onChange method from auth.js

* Add refactored fetch usage for searching

- Add accessAPI which is basically a helper to preset some commonly used config for fetch

* Add refactored InfoActions with new fetch

- Use accessAPI method in InfoActions

* Refactor login action to use accessAPI

* Add refactored logout LoginAction

* Add refactored logout action in LoginActions

* Remove unused /utils files

- Use default export in accessAPI.js

* Add more informative api request error messages

* Fix wrong last update usage in Info page

* Fix Jenkinsfile library branch

- Use master, not a deleted branch

* Feature/dockerfile (#31)

* Add Dockerfile and .dockerignore file

* Add env var to apiGateway config

- Use passed in env var for server url, so that we can pass in a docker url

* Remove misc notes from dockerfile

* Update README with better running instructions

* Update Jenkinsfile shared pipeline branch

* Fix/fetch promise refactor (#32)

* Add refactored fetch using promises

- Use promise rather than callback to make code more concise
- Leave in old accessAPI method until other *Actions are refactored

* Add refactore InfoActions using promises

- Fix bug where spinner would continue showing if an error had occured

* Fix bug relating to catching failed promises

* Remove old apiAccess method

- Refactor *Actions to use new accessAPI method

* Fix display of ErrorModal

- Convert to pure component
- Fix child ref table to use ApiAccess for API requests

* Feature/mock backend api (#33)

* Fix use of favicon in index.html

- Use properly formatted path

* Add fake request which mocks fetch

- All API requests pass the type of request (search/business/uiInfo etc) into accessAPI, so that URL's don't have to be parsed to find the endpoint
- Add /utils/request.js which will use the mocked fetch when it's in a test environment (REACT_APP_ENV)

* Make promise forming method more concise

* Move fakeFetch code into requestUtils

- Refactor code into small methods
- Fix ESLint error

* Add request dependancy to server package.json

* Remove unused bcrypt dependancy

* Reduce setTimeout when doing a fakeRequest

* Add .env file (remove from .gitignore)

* Fix/session classes (#34)

* Add proper use of OO inheritance in Sessions

- Each type of session extends the Session class
- Add documentation of Session methods
- Add pg dependancy to package.json

* Update Jenkinsfile Gitlab branch

* Fix PsqlSession pool creation bug

- Fix bug where just importing the PsqlSession class would trigger a new pool to be created, move this to an init method which is called from the constructor

* Remove unused CI.md README

* Feature/styles update (#35)

* Change REACT_APP_ENV value to 'test'

* Add assets for the new pattern library

- Add css to the /public directory
- Add logo image to /src/resources/img
- Remove old styles css import in index.js
- Update index.html to handle new CSS

* Remove unused dependancies, refactor ESLint

- Remove unused dependancies in package.json (react a11y)
- Remove unused eslint config section from package.json
- Add .vscode to .gitignore
- Remove unused routes

* Remove unused React components and utils

- Remove any unused views/components/helper methods
- Remove reducer/action/constant code relating to get ui/api info
- Remove unused config

* Fix ESLint issue with arrow functions

* Add updated Login page

- Add LoginAction for resetting the error message
- Add /patterns with Button/TextInput/LinkButton components
- Fix routes in routes file

* Refactor login page to use TextInput components

- Refactor TextInput to make it work with either refs or onChange

* Fix routing issue, refactor functional components

- Fix issue with SearchHOC (don't use it for now)

* Add Panel component for showing error/info/warn

* Add working search feature back in

- Add components to deal with the search (Business, ResultsList etc)
- Add redirect in ApiActions
- Fix exportJson method

* Fix industry code and multiple select inputs

* Remove unused files, refactor SearchHOC

- Remove unused assets
- Move onChange helpers to helperMethods for SearchHOC

* Fix issue with depracated replaceState params

* Fix documentation in all React classes

- Ensure documentation is consistent, e.g. no need to duplicate
prop details

* Refactor Redux related code, remove unused code

- Remove unused redux code (related to Match/range/ubrn)
- Move helper methods to /utils/helperMethods.js

* Fix documentation formatting

- Use consistent documentation format, where the parameters are only described where prop types isn't used

* Remove unused object.assign dependancy

* Remove verbose testing details from the README

* Add Pagination component and connect to Results

* Fix issue with <table> child, use <tbody>

- https://stackoverflow.com/questions/41716528/react-tr-cannot-appear-as-a-child-of-td-see-comment-td-tr

* Add ChildRefList component of child refs

* Fix ESLint errors

* Fix forming of the ES query

- Fix form query to work for generic queries
- Change env var back to local

* Use immutable set state, no mutating of state

- Use ES6 way of setting state immutably

* Add fix for searching on child ref (VAT/CH/PAYE)

* Fix use of plural businesses on Results page

* FIx issue with errorModal not showing on Home/Results

* Export helper method to fix unit test

* Add ESLint jsx-a11y to package.json to fix tests

* Fix https and password type issue

* Add type=text to SearchForm text inputs

* Add fix for text input sizes

* Remove sdc-main css (unused)

* Feature/styles update tests (#36)

* Add unit test for exportCSV method

* Add unit tests for formQuery

* Fix method and add test for formatData

* Add unit tests for other helperMethods code

* Fix/refs search (#37)

* Add fix for refs searching, add new fields

- Add new fields for CRN, VAT, PAYE search on SearchForm

* Remove unused code in formQuery.js

* Remove load test part of Jenkinsfile

* Add stress tests back in, fix unit test

* Add new unit tests for new formQuery inputs

* Fix/react 16 migration (#38)

* Add start of React 15 -> 15 migration

- Remove use of halogen for loading spinner, use fork which is compatible with react 16
- Upgrade react-router dependancy

* Fix use of React 16 for searching

- Fixed all features apart from 404 page and use of react-modal-dialog

* Fix 404 page display

* Refactor SearchForm to be functional component

* Change SearchForm to use props, no deconstruct

* Refactor code base to use Panel, not a modal

- Remove react-modal-dialog from package.json (not compatible with React 16 + we shouldn't be using it anyway)
- Refactor all uses of ErrorMessage to use a Panel instead
- Add props to Panel so that a close link can be used

* Feature/child refs hoc (#39)

* Refactor fetching of child refs into HOC

- ChildRefList/Table both have almost identical code for fetching /business/:id, so the common logic has been moved into a higher order component

* Add working use of HOC in ChildRefTable

* Fix/error modal bug (#40)

* Add fix for ChildRefList, use props not this.state

* Add fix for ChildRefTable, use props not state

* Fix/styles feedback fix (#43)

* Fix Button to use dynamic style/class props

- For the clear button, use secondary button type with border

* Remove username from Header.js

* Fix use of show references icons

- Add /img to /public
- Add chevron image to /src/resources

* Add capped badge if the results are capped

- Results cap at 10,000

* Add updated CSS for new search bar

* Seperate out SearchForm into different components

- Change props for button/textInput

* Add seperate search form for the home page

- Fix issue with TextInputInline not displaying the correct size

* Add fix for width of react-table (12 cols now)

* Fix column widths, fix issue with htmlFor in range input

* Fix more col widths, remove scroll in ResultsList

* Remove spacing from Home search inputs

* Fix spelling errors

- CN -> CRN
- Use 'Employment' instead of 'Employment Bands' in react table

* Add scroll to results feature

* Change scroll to go to Search header

* Feature/results capped at (#44)

* Add return of 'x-total-count' header

* Add display of panel showing number of results capped

- Add reducer/apiActions for setting capped results number
- Add allowed cors headers in the server for X-Total-Count
- Add return of X-Total-Count in apiGateway and api.js
- Modify accessApi.js to handle getting the headers

* Add unit test for new helperMethod

* Fix/mock fetch headers (#45)

* Add fix for mock fetch change of format

- From accessAPI we get a promise back with the response rather than a promise for the json

* Add better explanation of fetch issue

* Fix/export convert bands (#46)

* Add redux related code for exporting csv or json

* Add conversion of bands in csv/json download

* Use redux for the export of csv/json

* Add tests for export.js util

* Fix ESLint error (define before use)

* Fix/json fields update (#47)

* Fix JSON field accessor names

* Fix JSON fields in export.js

* Fix JSON fields for fake fetch functionality

* Fix tests with new JSON keys

@iffy
iffy

mentioned this issue

Nov 18, 2021

Содержание

  1. NodeJS Postgres error getaddrinfo ENOTFOUND
  2. 8 Answers 8
  3. Error: getaddrinfo ENOTFOUND when sending https request Node.js and API
  4. 3 Answers 3
  5. Linked
  6. Related
  7. Hot Network Questions
  8. Subscribe to RSS
  9. «Error: getaddrinfo ENOTFOUND» error when making an HTTPs request
  10. 4 Answers 4
  11. Error : getaddrinfo ENOTFOUND registry.npmjs.org registry.npmjs.org:443
  12. 17 Answers 17
  13. Update
  14. Update 2
  15. Update 3
  16. getaddrinfo ENOTFOUND api.telegram.org #99
  17. Comments

NodeJS Postgres error getaddrinfo ENOTFOUND

I use pg://user:pass@localhost:port/table for connecting to my AWS database. When I use localhost, the app works fine, but when I try to connect the AWS server it falls apart.

Even a simple connection code gives me this error. The database name is people and it’s running on port 8080 but in this error it’s showing 5432 even if I declare the correct port number in the conString.

Error: getaddrinfo ENOTFOUND people people:5432 at errnoException (dns.js:26:10) at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:77:26)

This is my code so far:

8 Answers 8

If you’re sure your connection string is already well-formed like the one gnerkus described, the last thing you need to check is your password. If it’s contain non alphanumeric characters, maybe that’s the one who cause the issue. It seems either the Node.js or the way javascript work itself causing this (I’m not really sure since pg-admin can connect using my initial password just fine).

My password was contain ‘+’ and ‘/’ (acquired by creating a long json filled with gibberish and then hash it resulting base64 string) and I sure does receiving the same error like yours. Once I get rid of it (from my connection string and updating my database’s password), it’s working fine.

Oh, and . ‘=’ is accepted though. Because it seems the problem is with url decoding process at the database side. When I sent ‘+’ , I think it replaced by ‘ ‘ which will cause incorrect password. And the ‘/’ was causing malformed url which is the root cause of our error (which says not found). Take a look at this example.

I’m sure you’ll realize that there are extra ‘/’ which will cause wrong url break down. So, protocol:// user:pass@host / database changed into protocol:// [malformed user:pass@host] / [malformed database name] / [some gibberish] because of that extra ‘/’ .

If your colleague who access it using JSF can edit their connection string, I suggest to update the password to one which accepted by both. If they can’t, then you need to create another user/role with same access right but different password that can be used from Node.js.

EDIT: Or better yet, according to discussion here, try encode the password part of your connection string. They say it works. I didn’t bother to try it since I already change my password. Since you still has this issue, you might want to try it first before doing one of my two suggestions above.

Источник

Error: getaddrinfo ENOTFOUND when sending https request Node.js and API

I am developing a dashboard, I need to conect to a API and catch a Auth Token and afther that send info by using a HTTPS protocol. I use a Nodejs, and when I run my code I have the next error on the pm2 monit:

Also here is my code where I made the request (Node.js):

Here is the rest of the code:

3 Answers 3

Remove protocol, and use domain names only for the host. For instance:

See documentation for the http.request options.

It seems that is trying to getaddrinfo of the full url, instead of just the hostname. I would put hostname in option as only «my.url.net» and update path with the rest of the url.

@Eric0607 the error stackoverflow.com/questions/65810720/… you’ve provided is not showing anymore, I might’ve been too late to reply.

but in case you got «an invalid local cert SSL error«, here is a fix I found that works for it. disable SSL check in your code, not recommended but it would work temporarily, turn it on after you’re done or it can be risky.

Linked

Hot Network Questions

To subscribe to this RSS feed, copy and paste this URL into your RSS reader.

Site design / logo © 2023 Stack Exchange Inc; user contributions licensed under CC BY-SA . rev 2023.1.14.43159

By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.

Источник

«Error: getaddrinfo ENOTFOUND» error when making an HTTPs request

Part of AWS Collective

here’s the code in AWS Lambda function:

Error: getaddrinfo ENOTFOUND https://bittrex.com https://bittrex.com:443 at errnoException (dns.js:28:10) at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:76:26)

Other solutions did not work.

4 Answers 4

Remove the https:// from the host. The require already says you’re using https/SSL.

I modified your code to work correctly in AWS Lambda Node.js 6.10. I set the Lambda timeout to be 60 seconds for testing.

The big change is adding «res.on(‘data’, function(chunk) <>:» and «res.on(‘end’, function() <>«.

The issue is with your security groups. Looks like your lambda doesn’t have access to resolve DNS. Check if you lambda sec groups have port 53 UDP and TCP enabled.

Also Make sure the lambda attempts to reach a reachable host. in other words make sure that the host doesn’t reside in a private network / VPN / or an unreachable network (that can’t be reached from the externally)

(Trivial but still worth mentioning)

This question is in a collective: a subcommunity defined by tags with relevant content and experts.

Источник

Error : getaddrinfo ENOTFOUND registry.npmjs.org registry.npmjs.org:443

I am working on a corporate network.

Trying to install npm. But I’m getting this error again and again.

Tried this also: npm config set registry https://registry.npmjs.org/

Still getting the same error.

17 Answers 17

  1. make sure you have internet connection: ping 8.8.8.8
  2. make sure you have DNS resolver working: ping www.google.com
  3. make sure you can access registry.npmjs.org: ping registry.npmjs.org
  4. make sure you can connect via https.

Make sure you are trying to connect to:

or some other weird string composed of few hostnames, because it’s weird that the resolver complains about a hostnames that includes a port number, which it shouldn’t care about. Ok, I tested and it should look like this for hosts that are not found.

Update

From your comment to this answer it seems that you are not directly connected to the internet if you can’t even ping 8.8.8.8.

If you are using a proxy to access the Web, then you also have to configure npm to use it. Use:

but instead of http://example.com:8080 use what you actually need in your company — ask someone or see how your browser is configured.

To see your proxy configuration in Chrome, see this.

Update 2

If you can access https://registry.npmjs.org/ in your browser but you cannot run ping registry.npmjs.org then it means that your browser must be configured to use a proxy, or other programs than your browser must be restricted from using the internet.

In any case, you should ask someone in your company about it because most likely you either need to use a specific proxy or someone needs to lift the restriction from your npm and allow it to access the network.

The network access can be blocked by a firewall installed on your computer or a router in your network. It’s hard to say without knowing the specific configuration in your company.

Update 3

Remove the environment variable «https_proxy» if any or use correct value for «https_proxy»

Источник

getaddrinfo ENOTFOUND api.telegram.org #99

This error every day. I think it’s because long plain. Maybe add live reload when exception?

The text was updated successfully, but these errors were encountered:

This problem makes the OS reboot

  • Upgrade your Node.js version (may overcome this error)
  • Flush your DNS
  • Reboot your machine (SO answer)

Please provide us with feedback.

I’m having a similar issue:

«node-telegram-bot-api»: «^0.24.0»,
npm -v 4.0.5
node -v v7.2.1

The nodejs application is running inside docker container, but it used to work nice until started raising this errors..

My bot is inside a Docker, I just stopped it and start again and everything was ok.

i have this issue all the time. restarting it does nothing because since i’ve got the latest version of node.js it completely shuts node down and the container goes down, so its constantly restarting all the time. network is bridged so it does have internet just fine. its its own container so dns cache shouldn’t even be a thing since containers are cleared upon reboot.

@dianjuar @MothGirlMusic not sure if you sorted your issue, but sometimes this ENOTFOUND issue is due to the underlying system not finding an IPv6 address for the host.

Some people report here adding family: 4 to the request() options does the trick (forces it to look for the IPv4 address, which should be findable).

It looks like request() options can be passed (see «request.options» on this page):

It’s actually still not solved after 6 years

if you are using docker try to restart it, it works fine with me after restarting docker service

I also get sometimes getaddrinfo EAI_AGAIN api.telegram.org , often after a system reboot. And yes my DNS resolver is correctly configured.

My guess is that Docker is actually starting-up faster the Docker container than my system network / DNS resolver is ready to handle the requests. Something like that.

My bet is that my systemd is missing requires network dependency (see: Requires: ) in the Docker service file:

Although I see that containerd.service requires network.target as dependency. Maybe this isn’t enough or on the wrong level or it should use network-online.target instead of network.target ? Or After=network-online.target Wants=network-online.target or maybe better: After=nss-lookup.target should be added.

Restarting the specific docker container manually always fixes the issue.

I already have a error handling, but it will not catch this getaddrinfo issue (so this code snipped will NOT help you):

Looking at the error traces, I suspect the request-promise package that throws this error. Which is used by in the internal function _request() .

Once you catched the getaddrinfo error, you can maybe set a global state in an error state. Add a health check to Docker, so Docker will automatically restart the Docker image to try again. Most likely this will be the best solution, since after a server reboot the Docker container is started before the DNS is ready. Restarting the Docker container only once would resolve the error for now.

@yagop Ideally the node-telegram-bot-api code should be robust for this error and have built-in a retry mechanism. So the bot doesn’t completely fail and stop working if this issue triggered only once.

Источник

You will encounter various kinds of errors while developing Node.js
applications, but most can be avoided or easily mitigated with the right coding
practices. However, most of the information to fix these problems are currently
scattered across various GitHub issues and forum posts which could lead to
spending more time than necessary when seeking solutions.

Therefore, we’ve compiled this list of 15 common Node.js errors along with one
or more strategies to follow to fix each one. While this is not a comprehensive
list of all the errors you can encounter when developing Node.js applications,
it should help you understand why some of these common errors occur and feasible
solutions to avoid future recurrence.

🔭 Want to centralize and monitor your Node.js error logs?

Head over to Logtail and start ingesting your logs in 5 minutes.

1. ECONNRESET

ECONNRESET is a common exception that occurs when the TCP connection to
another server is closed abruptly, usually before a response is received. It can
be emitted when you attempt a request through a TCP connection that has already
been closed or when the connection is closed before a response is received
(perhaps in case of a timeout). This exception will usually
look like the following depending on your version of Node.js:

Output

Error: socket hang up
    at connResetException (node:internal/errors:691:14)
    at Socket.socketOnEnd (node:_http_client:466:23)
    at Socket.emit (node:events:532:35)
    at endReadableNT (node:internal/streams/readable:1346:12)
    at processTicksAndRejections (node:internal/process/task_queues:83:21) {
  code: 'ECONNRESET'
}

If this exception occurs when making a request to another server, you should
catch it and decide how to handle it. For example, you can retry the request
immediately, or queue it for later. You can also investigate your timeout
settings if you’d like to wait longer for the request to be
completed.

On the other hand, if it is caused by a client deliberately closing an
unfulfilled request to your server, then you don’t need to do anything except
end the connection (res.end()), and stop any operations performed in
generating a response. You can detect if a client socket was destroyed through
the following:

app.get("/", (req, res) => {
  // listen for the 'close' event on the request
  req.on("close", () => {
    console.log("closed connection");
  });

  console.log(res.socket.destroyed); // true if socket is closed
});

2. ENOTFOUND

The ENOTFOUND exception occurs in Node.js when a connection cannot be
established to some host due to a DNS error. This usually occurs due to an
incorrect host value, or when localhost is not mapped correctly to
127.0.0.1. It can also occur when a domain goes down or no longer exists.
Here’s an example of how the error often appears in the Node.js console:

Output

Error: getaddrinfo ENOTFOUND http://localhost
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:71:26) {
  errno: -3008,
  code: 'ENOTFOUND',
  syscall: 'getaddrinfo',
  hostname: 'http://localhost'
}

If you get this error in your Node.js application or while running a script, you
can try the following strategies to fix it:

Check the domain name

First, ensure that you didn’t make a typo while entering the domain name. You
can also use a tool like DNS Checker to confirm that
the domain is resolving successfully in your location or region.

Check the host value

If you’re using http.request() or https.request() methods from the standard
library, ensure that the host value in the options object contains only the
domain name or IP address of the server. It shouldn’t contain the protocol,
port, or request path (use the protocol, port, and path properties for
those values respectively).

// don't do this
const options = {
  host: 'http://example.com/path/to/resource',
};

// do this instead
const options = {
  host: 'example.com',
  path: '/path/to/resource',
};

http.request(options, (res) => {});

Check your localhost mapping

If you’re trying to connect to localhost, and the ENOTFOUND error is thrown,
it may mean that the localhost is missing in your hosts file. On Linux and
macOS, ensure that your /etc/hosts file contains the following entry:

You may need to flush your DNS cache afterward:

sudo killall -HUP mDNSResponder # macOS

On Linux, clearing the DNS cache depends on the distribution and caching service
in use. Therefore, do investigate the appropriate command to run on your system.

3. ETIMEDOUT

The ETIMEDOUT error is thrown by the Node.js runtime when a connection or HTTP
request is not closed properly after some time. You might encounter this error
from time to time if you configured a timeout on your
outgoing HTTP requests. The general solution to this issue is to catch the error
and repeat the request, preferably using an
exponential backoff
strategy so that a waiting period is added between subsequent retries until the
request eventually succeeds, or the maximum amount of retries is reached. If you
encounter this error frequently, try to investigate your request timeout
settings and choose a more appropriate value for the endpoint
if possible.

4. ECONNREFUSED

The ECONNREFUSED error is produced when a request is made to an endpoint but a
connection could not be established because the specified address wasn’t
reachable. This is usually caused by an inactive target service. For example,
the error below resulted from attempting to connect to http://localhost:8000
when no program is listening at that endpoint.

Error: connect ECONNREFUSED 127.0.0.1:8000
    at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1157:16)
Emitted 'error' event on ClientRequest instance at:
    at Socket.socketErrorListener (node:_http_client:442:9)
    at Socket.emit (node:events:526:28)
    at emitErrorNT (node:internal/streams/destroy:157:8)
    at emitErrorCloseNT (node:internal/streams/destroy:122:3)
    at processTicksAndRejections (node:internal/process/task_queues:83:21) {
  errno: -111,
  code: 'ECONNREFUSED',
  syscall: 'connect',
  address: '127.0.0.1',
  port: 8000
}

The fix for this problem is to ensure that the target service is active and
accepting connections at the specified endpoint.

5. ERRADDRINUSE

This error is commonly encountered when starting or restarting a web server. It
indicates that the server is attempting to listen for connections at a port that
is already occupied by some other application.

Error: listen EADDRINUSE: address already in use :::3001
    at Server.setupListenHandle [as _listen2] (node:net:1330:16)
    at listenInCluster (node:net:1378:12)
    at Server.listen (node:net:1465:7)
    at Function.listen (/home/ayo/dev/demo/node_modules/express/lib/application.js:618:24)
    at Object.<anonymous> (/home/ayo/dev/demo/main.js:16:18)
    at Module._compile (node:internal/modules/cjs/loader:1103:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1157:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
Emitted 'error' event on Server instance at:
    at emitErrorNT (node:net:1357:8)
    at processTicksAndRejections (node:internal/process/task_queues:83:21) {
  code: 'EADDRINUSE',
  errno: -98,
  syscall: 'listen',
  address: '::',
  port: 3001
}

The easiest fix for this error would be to configure your application to listen
on a different port (preferably by updating an environmental variable). However,
if you need that specific port that is in use, you can find out the process ID
of the application using it through the command below:

Output

COMMAND  PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
node    2902  ayo   19u  IPv6 781904      0t0  TCP *:3001 (LISTEN)

Afterward, kill the process by passing the PID value to the kill command:

After running the command above, the application will be forcefully closed
freeing up the desired port for your intended use.

6. EADDRNOTAVAIL

This error is similar to EADDRINUSE because it results from trying to run a
Node.js server at a specific port. It usually indicates a configuration issue
with your IP address, such as when you try to bind your server to a static IP:

const express = require('express');
const app = express();

const server = app.listen(3000, '192.168.0.101', function () {
  console.log('server listening at port 3000......');
});

Output

Error: listen EADDRNOTAVAIL: address not available 192.168.0.101:3000
    at Server.setupListenHandle [as _listen2] (node:net:1313:21)
    at listenInCluster (node:net:1378:12)
    at doListen (node:net:1516:7)
    at processTicksAndRejections (node:internal/process/task_queues:84:21)
Emitted 'error' event on Server instance at:
    at emitErrorNT (node:net:1357:8)
    at processTicksAndRejections (node:internal/process/task_queues:83:21) {
  code: 'EADDRNOTAVAIL',
  errno: -99,
  syscall: 'listen',
  address: '192.168.0.101',
  port: 3000
}

To resolve this issue, ensure that you have the right IP address (it may
sometimes change), or you can bind to any or all IPs by using 0.0.0.0 as shown
below:

var server = app.listen(3000, '0.0.0.0', function () {
  console.log('server listening at port 3000......');
});

7. ECONNABORTED

The ECONNABORTED exception is thrown when an active network connection is
aborted by the server before reading from the request body or writing to the
response body has completed. The example below demonstrates how this problem can
occur in a Node.js program:

const express = require('express');
const app = express();
const path = require('path');

app.get('/', function (req, res, next) {
  res.sendFile(path.join(__dirname, 'new.txt'), null, (err) => {
    console.log(err);
  });
  res.end();
});

const server = app.listen(3000, () => {
  console.log('server listening at port 3001......');
});

Output

Error: Request aborted
    at onaborted (/home/ayo/dev/demo/node_modules/express/lib/response.js:1030:15)
    at Immediate._onImmediate (/home/ayo/dev/demo/node_modules/express/lib/response.js:1072:9)
    at processImmediate (node:internal/timers:466:21) {
  code: 'ECONNABORTED'
}

The problem here is that res.end() was called prematurely before
res.sendFile() has had a chance to complete due to the asynchronous nature of
the method. The solution here is to move res.end() into sendFile()‘s
callback function:

app.get('/', function (req, res, next) {
  res.sendFile(path.join(__dirname, 'new.txt'), null, (err) => {
    console.log(err);
    res.end();
  });
});

8. EHOSTUNREACH

An EHOSTUNREACH exception indicates that a TCP connection failed because the
underlying protocol software found no route to the network or host. It can also
be triggered when traffic is blocked by a firewall or in response to information
received by intermediate gateways or switching nodes. If you encounter this
error, you may need to check your operating system’s routing tables or firewall
setup to fix the problem.

9. EAI_AGAIN

Node.js throws an EAI_AGAIN error when a temporary failure in domain name
resolution occurs. A DNS lookup timeout that usually indicates a problem with
your network connection or your proxy settings. You can get this error when
trying to install an npm package:

Output

npm ERR! code EAI_AGAIN
npm ERR! syscall getaddrinfo
npm ERR! errno EAI_AGAIN
npm ERR! request to https://registry.npmjs.org/nestjs failed, reason: getaddrinfo EAI_AGAIN registry.npmjs.org

If you’ve determined that your internet connection is working correctly, then
you should investigate your DNS resolver settings (/etc/resolv.conf) or your
/etc/hosts file to ensure it is set up correctly.

10. ENOENT

This error is a straightforward one. It means «Error No Entity» and is raised
when a specified path (file or directory) does not exist in the filesystem. It
is most commonly encountered when performing an operation with the fs module
or running a script that expects a specific directory structure.

fs.open('non-existent-file.txt', (err, fd) => {
  if (err) {
    console.log(err);
  }
});

Output

[Error: ENOENT: no such file or directory, open 'non-existent-file.txt'] {
  errno: -2,
  code: 'ENOENT',
  syscall: 'open',
  path: 'non-existent-file.txt'
}

To fix this error, you either need to create the expected directory structure or
change the path so that the script looks in the correct directory.

11. EISDIR

If you encounter this error, the operation that raised it expected a file
argument but was provided with a directory.

// config is actually a directory
fs.readFile('config', (err, data) => {
  if (err) throw err;
  console.log(data);
});

Output

[Error: EISDIR: illegal operation on a directory, read] {
  errno: -21,
  code: 'EISDIR',
  syscall: 'read'
}

Fixing this error involves correcting the provided path so that it leads to a
file instead.

12. ENOTDIR

This error is the inverse of EISDIR. It means a file argument was supplied
where a directory was expected. To avoid this error, ensure that the provided
path leads to a directory and not a file.

fs.opendir('/etc/passwd', (err, _dir) => {
  if (err) throw err;
});

Output

[Error: ENOTDIR: not a directory, opendir '/etc/passwd'] {
  errno: -20,
  code: 'ENOTDIR',
  syscall: 'opendir',
  path: '/etc/passwd'
}

13. EACCES

The EACCES error is often encountered when trying to access a file in a way
that is forbidden by its access permissions. You may also encounter this error
when you’re trying to install a global NPM package (depending on how you
installed Node.js and npm), or when you try to run a server on a port lower
than 1024.

fs.readFile('/etc/sudoers', (err, data) => {
  if (err) throw err;
  console.log(data);
});

Output

[Error: EACCES: permission denied, open '/etc/sudoers'] {
  errno: -13,
  code: 'EACCES',
  syscall: 'open',
  path: '/etc/sudoers'
}

Essentially, this error indicates that the user executing the script does not
have the required permission to access a resource. A quick fix is to prefix the
script execution command with sudo so that it is executed as root, but this is
a bad idea
for security reasons.

The correct fix for this error is to give the user executing the script the
required permissions to access the resource through the chown command on Linux
in the case of a file or directory.

sudo chown -R $(whoami) /path/to/directory

If you encounter an EACCES error when trying to listen on a port lower than
1024, you can use a higher port and set up port forwarding through iptables.
The following command forwards HTTP traffic going to port 80 to port 8080
(assuming your application is listening on port 8080):

sudo iptables -t nat -I PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080

If you encounter EACCES errors when trying to install a global npm package,
it usually means that you installed the Node.js and npm versions found in your
system’s repositories. The recommended course of action is to uninstall those
versions and reinstall them through a Node environment manager like
NVM or Volta.

14. EEXIST

The EEXIST error is another filesystem error that is encountered whenever a
file or directory exists, but the attempted operation requires it not to exist.
For example, you will see this error when you attempt to create a directory that
already exists as shown below:

const fs = require('fs');

fs.mkdirSync('temp', (err) => {
  if (err) throw err;
});

Output

Error: EEXIST: file already exists, mkdir 'temp'
    at Object.mkdirSync (node:fs:1349:3)
    at Object.<anonymous> (/home/ayo/dev/demo/main.js:3:4)
    at Module._compile (node:internal/modules/cjs/loader:1099:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:975:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
    at node:internal/main/run_main_module:17:47 {
  errno: -17,
  syscall: 'mkdir',
  code: 'EEXIST',
  path: 'temp'
}

The solution here is to check if the path exists through fs.existsSync()
before attempting to create it:

const fs = require('fs');

if (!fs.existsSync('temp')) {
  fs.mkdirSync('temp', (err) => {
    if (err) throw err;
  });
}

15. EPERM

The EPERM error may be encountered in various scenarios, usually when
installing an npm package. It indicates that the operation being carried out
could not be completed due to permission issues. This error often indicates that
a write was attempted to a file that is in a read-only state although you may
sometimes encounter an EACCES error instead.

Here are some possible fixes you can try if you run into this problem:

  1. Close all instances of your editor before rerunning the command (maybe some
    files were locked by the editor).
  2. Clean the npm cache with npm cache clean --force.
  3. Close or disable your Anti-virus software if have one.
  4. If you have a development server running, stop it before executing the
    installation command once again.
  5. Use the --force option as in npm install --force.
  6. Remove your node_modules folder with rm -rf node_modules and install them
    once again with npm install.

Conclusion

In this article, we covered 15 of the most common Node.js errors you are likely
to encounter when developing applications or utilizing Node.js-based tools, and
we discussed possible solutions to each one. This by no means an exhaustive list
so ensure to check out the
Node.js errors documentation or the
errno(3) man page for a
more comprehensive listing.

Thanks for reading, and happy coding!

Check Uptime, Ping, Ports, SSL and more.

Get Slack, SMS and phone incident alerts.

Easy on-call duty scheduling.

Create free status page on your domain.

Got an article suggestion?
Let us know

Share on Twitter

Share on Facebook

Share via e-mail

Next article

How to Configure Nginx as a Reverse Proxy for Node.js Applications

Licensed under CC-BY-NC-SA

This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

Понравилась статья? Поделить с друзьями:
  • Request error character name is wrong перевод
  • Request does not match any route pocketbook как исправить
  • Request contains an invalid argument youtube как исправить
  • Requ 106 ошибка вольво
  • Republic at war missing как исправить