Debugging

Basics

Identifying and preventing bugs.

Tags

debug

Debug Cycle

Identify

The sooner the better. Find bug during

Isolate

What context does the bug exist in.

What state does it occur in.

Use context and recreate state to find root cause.

Resolve

Discuss the associated risks, changes, and impacts in implementing an immediate unstable fix vs a later stable fix.

Prevent

Steps to prevent bug from occurring again.

Process Change

Automate a manual process.

Regression Test

Test that looks for a recurrence of a bug.

Chrome Debbugger Tool

Preserve Log

Keeps logs after any state changes.

Async

Tracks asynchronous calls between functions.

Blackbox Script

Right click on a file you do not want to show in the debugger , click blackbox script.

Useful for decluttering console view by not including imported libraries during debugging.

Not included files are grayed out.

Application Tab

Shows web app info such as

Network Tab

For viewing server status codes.

Profiles Tab

For viewing memory allocation.

Record Allocation Timeline

Helps troubleshoot memory leaks. Record for about 30s.

Blue bars indicate memory used and retained.

Expected behaviour is that long blue lines are followed by short blue lines to indicate memory is being released back.

Save profile to show snapshot of site performance at various points throughout development cycle.

Timeline Tab

For displaying FPS.

For identifying memory leaks.

Record memory while interacting with the site for about 30s.

Top section shows FPS,CPU,HEAP

Select area around blue line.

Second section shows more detail with waterfall view.

w zoom in

s zoom out

a move left

d move right

Bug Types

Logical

When preventing any default behaviour make sure to provide alternate behaviour.

Consider if an empty string is a valid value for your function.

Data

Make sure to only allow valid requests.

Do not submit an empty form. Have JS validate input as string and non empty. Add a required attribute to the html element for user feedback.

Server may send an unexpected data type.

Write code to catch these edge occurrences.

Memory

Performance

Combine multiple files into one file to reduce multiple call requests.

Minify and gzip files such as css and js.

Compress images and use correct resolution sizes.

Network

Can lead to missing assets or dropped data.

Best to have a catch for that scenario and provide the user with a message informing them of what may have happened and offer some options.

JS can be turned off.

Inform the user.

Third Party Errors

You can send them a bug fix report.

Best to make a copy of the library and package it locally.

Preventative Development

Avoid use of third party code for critical infrastructure.

This allows for more effective unit testing.

This tracks types of bugs and their location. Which helps identify modules or systems that require restructuring.

Tips

Have a user account in order to interact with the site as an actual user.

notes navigation

Current URL: /notes/06Debugging/00-debug-basics/

total notes 36